Skip to content

Instantly share code, notes, and snippets.

@reu
Created October 6, 2011 00:49
Show Gist options
  • Save reu/1266189 to your computer and use it in GitHub Desktop.
Save reu/1266189 to your computer and use it in GitHub Desktop.
class User
has_many :posts
end
class Post
belongs_to :user
has_many :comments
def self.search(comment_description)
joins(:comments).where(:comments => { :description => comment_description })
end
end
class Comment
belongs_to :post
end
User.first.posts.search("Comentario idiota")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment