How to get column_for_attribute?

Hi all,
In the code below I don’t understand:

  1. Why I have to prepend overriden method content_columns with “self.”
    to get it working?
  2. Why column_for_attribute method is not working (no such method?) even
    if SomeTable is subclass of ActiveRecord::Base which have public
    column_for_attribute method?

class SomeTable < ActiveRecord::Base

def self.content_columns
column = column_for_attribute(‘sometable_id’)
super
end
end
Any help is appreciated.
Bojan M.


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
→ tools, scripts, tricks from our code lab: http://source.mihelac.org

I am come with these conclusions so far, please :

  1. Why I have to prepend overriden method content_columns with “self.”
    to get it working?
    ‘content_columns’ is class method of ActiveRecord::Base, so it should be
    defined as:
    def Base.content_columns
    if we want to override it, right?
  2. Why column_for_attribute method is not working (no such method?)
    even if SomeTable is subclass of ActiveRecord::Base which have public
    column_for_attribute method?
    ‘content_columns’ is a class method and cannot call
    ‘column_for_attribute’ which is object method, right?
    However, this would work:
    column = columns_hash[‘sometable_id’]
    And original example:

class SomeTable < ActiveRecord::Base

def self.content_columns
column = column_for_attribute(‘sometable_id’)
super
end
end


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
→ tools, scripts, tricks from our code lab: http://source.mihelac.org