Hey, but i did not rename it. My model hasn't methods called busyness_category! I though AR generates them according to first argument to 'belongs_to' method, rather than from foreign key name
понедельник, 29 июня 2015 г., 17:05:42 UTC+3 пользователь Dave Aronson написал: > > On Monday, June 29, 2015, Мурыгин Антон <[email protected] <javascript:>> > wrote: > >> >> class Business < ActiveRecord::Base >> belongs_to :category, class_name: 'BusinessCategory', foreign_key: >> 'business_category_id' >> >> def category >> super || BusinessCategory.new(name: 'other') >> end >> end >> >> Why it keeps throwing >> >> super: no superclass method `category' for #<Business:0x000001023014b8> >> >> ? >> > > Possibly because AR::Base has no idea about your renaming of that > association. Try calling that method business_category instead, or call > business_category instead of super. (Just don't do both,) > > > -- > Sent from Gmail Mobile; please excuse top posting, typos, etc. :-( > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/58367a31-7dba-4d0a-9bbd-3a4ada3d14bb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

