regarding class_inheritable_accessor

By looking at the implementation of class_inheritable_accessor by ActiveSupport, looks like it is defining not only class methods as well as instance methods. Whats the reason behind defining both class level as well as instance level methods. Is there any alternative function that defines just the class level methods.

Please see below for my requirement:

I have a model Page for which I would like to define class level variable "title" that can be overridden in its subclasses. But I also have a column in the pages table by the name "title". But by using class_inheritable_accessor, I am getting nil for @page.title.

Thanks in advance.

Saty Nos wrote:

By looking at the implementation of class_inheritable_accessor by ActiveSupport, looks like it is defining not only class methods as well as instance methods. Whats the reason behind defining both class level as well as instance level methods. Is there any alternative function that defines just the class level methods.

Please see below for my requirement:

I have a model Page for which I would like to define class level variable "title" that can be overridden in its subclasses. But I also have a column in the pages table by the name "title". But by using class_inheritable_accessor, I am getting nil for @page.title.

Thanks in advance.

Declaring remove_method after the declaration of class_inheritable_accessor seems to do the trick, although not sure about the ramifications at this point, partly due to the lack of knowledge of why rails is defining the instance methods in the first place. Would appreciate if someone could shed the light.

-Satynos