Skip to content

Instantly share code, notes, and snippets.

@releu
Created April 26, 2012 06:07
Show Gist options
  • Save releu/2496444 to your computer and use it in GitHub Desktop.
Save releu/2496444 to your computer and use it in GitHub Desktop.
Working example of inverse_of
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