multiple_table_inheritance icon indicating copy to clipboard operation
multiple_table_inheritance copied to clipboard

Cannot call find_by_* in children if attribute belongs to parent

Open danivalentin opened this issue 12 years ago • 3 comments

If I have "title" in my superclass, I can't call "find_by_title" directly from its children. Error I get is that the method doesn't exist.

danivalentin avatar Oct 04 '12 23:10 danivalentin

Hey danivalentin - did you try specifying the :methods option when calling inherits_from? Check out the Methods section of the README. Let me know if it still doesn't work.

mhuggins avatar Oct 05 '12 14:10 mhuggins

hi Matt!

yes, I'm using :methods => true. Is there anything else I need to do?

BTW, thanks for the gem!

danivalentin avatar Oct 05 '12 15:10 danivalentin

This sounds like a legitimate bug, but it may pertain to an issue in ActiveRecord as opposed to my gem. The reason I think that may be the case relates to a recent StackOverflow question I opened, in which I learned that ActiveRecord models don't return true when calling respond_to? for find_by_* methods.

This is likely the culprit, but I will verify and see if there is a fix or workaround.

mhuggins avatar Oct 05 '12 16:10 mhuggins