Create or override Rails Active Record macros (

Posted by Jocelyn on Stack Overflow See other posts from Stack Overflow or by Jocelyn
Published on 2014-06-13T08:36:52Z Indexed on 2014/06/13 9:25 UTC
Read the original article Hit count: 199

In a Rails app, Active Record creates created_at and updated_at columns thank to macros, (it seems to be also called "magic columns").

See Active Record Migrations

I have some questions about that mecanism:

  • Is it possible to override that to get a third column (e.g. deleted_at) ?
  • Is it possible to create a new macro t.publishing that will create publish_up and publish_down columns, for example?
  • And where to code that?

Obviously, I know I can add those columns manually, but I wonder how to achieve it with macros.

Working on Rails 4.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about macros