Open msolovyov opened 13 years ago
For example when having such a scenario
class Post include SimplyStored::Couch
belongs_to :owner, :class_name => "User" end
class User include SimplyStored::Couch
has_many :creations, :foreign_key => "owner_id"
end
When wanting to add a post to a user by going user.add_post, an error will be thrown saying: NoMethodError: undefined method `user_id='
This fix checks for a foreign_key in the options and sets that as the one to use.
For example when having such a scenario
class Post include SimplyStored::Couch
belongs_to :owner, :class_name => "User" end
class User include SimplyStored::Couch
has_many :creations, :foreign_key => "owner_id"
end
When wanting to add a post to a user by going user.add_post, an error will be thrown saying: NoMethodError: undefined method `user_id='
This fix checks for a foreign_key in the options and sets that as the one to use.