Hi! I saw that i documentation here
self.old_owner = self.owner
super
endend
If your model class is Project, the module is named
Project::GeneratedFeatureMethods. The GeneratedFeatureMethods module is
included in the model class immediately after the (anonymous) generated
attributes methods module, meaning an association will override the methods
for an attribute with the same name.
Now this is my model
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
? Am i missing something?
On Monday, June 29, 2015, Мурыгин Антон [email protected] wrote:
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.
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 A.
написал:
My rails version is 4.2.2.
понедельник, 29 июня 2015 г., 20:00:27 UTC+3 пользователь Frederick
Cheung
написал:
On Monday, June 29, 2015 at 7:40:58 PM UTC+1, Мурыгин Антон wrote:
My rails version is 4.2.2.
Weird - I created a fresh rails app, added a business model like yours
and
it works fine. I’d recommended doing the same and seeing whether you can
isolate what it is about your app that is different (for example is
Business::GeneratedAssociationMethods in the ancestor chain for
business?
What does Profile::GeneratedAssociationMethods.instance_methods look
like?)
Fred
On Monday, June 29, 2015, Мурыгин Антон [email protected] wrote:
Why it keeps throwing
super: no superclass method `category’ for #Business:0x000001023014b8
? Am i missing something?
Which version of rails?
Fred
Oh yeah, this is because of one gem i use that extends AR in that way.
Thanks that you set up fresh app, that helped me.
вторник, 30 июня 2015 г., 14:24:02 UTC+3 пользователь Frederick C.
написал: