Revision: 24743
Updated Code
at March 10, 2010 06:10 by nflamel
Updated Code
class Post < ActiveRecord::Base has_many :comments named_scope :commented_by, lambda { |user_id| { :joins => :comments, :conditions => ["comments.user_id = ?", user_id] } } end class Comment < ActiveRecord::Base belongs_to :user belongs_to :post end
Revision: 24742
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 10, 2010 06:09 by nflamel
Initial Code
class Post < ActiveRecord::Base has_many :comments named_scope :commented_by, lambda { |user_id| { :joins => :comments, :conditions => ["comments.user_id == ?", user_id] } } end class Comment < ActiveRecord::Base belongs_to :user belongs_to :post end
Initial URL
Initial Description
Initial Title
named_scope with joins
Initial Tags
rails
Initial Language
Rails