Hi! I saw that i documentation here - http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
Overriding generated methods
Association methods are generated in a module that is included into the model class, which allows you to easily override with your own methods and call the original generated method with
super. For example:
class Car < ActiveRecord::Base belongs_to :owner belongs_to :old_owner def owner=(new_owner) self.old_owner = self.owner super end end
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’
super || BusinessCategory.new(name: ‘other’)
Why it keeps throwing
super: no superclass method `category' for #<Business:0x000001023014b8>
? Am i missing something?