Hi guys,
I want to define my own Content_colums methode as part of the
ActiveRecord::Base class.
To do so, I have added the following code:
[Environment.rb]
require ‘model_extensions’
ActiveRecord::Base.send(:extend, ModelExtensions)
[model_extensions.rb]
module ModelExtensions
#Define Mixins for the ActiveRecord::Base modelclass
Define list of available items for select
def valid_items(current_item=nil)
#… works fine
end
Overwrite displayble columns attribute, eliminate: created_* and
updated_*
def content_columns
@content_columns ||= columns.reject { |c| c.primary || c.name =~
/(id|count)$/ || c.name == inheritance_column || c.name ==
locking_column || c.name =~ /(created|updated)/}
end
end
However, this won’t work for the content_columns! The valid_items method
though works perfectly as it is added to the AR:Base class.
But overwriting content_columns has no effect at all.
I tried to put ‘attr :content_columns, true’ but no effect neither
Any clues?