Created
April 26, 2012 06:07
-
-
Save releu/2496444 to your computer and use it in GitHub Desktop.
Working example of inverse_of
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post < AR::Base | |
has_many :comments, :inverse_of => :post | |
end | |
class Comment < AR::Base | |
belongs_to :post, :inverse_of => :comments | |
end | |
Comment.new.build_posts.comments == [Comment] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment