peritor / simply_stored

A convenience wrapper around CouchDB (using CouchPotato) that supports relations and S3 attachments
Other
140 stars 16 forks source link

has_many not taking into account belongs_to foreign key fix #18

Open msolovyov opened 13 years ago

msolovyov commented 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.