Rails 2.3 using another model's named_scope or alternative
- by mustafi
Hi
Let's say I have two models like so:
class Comment < ActiveRecord::Base
belongs_to :user
named_scope :about_x :conditions => "comments.text like '%x%')"
end
class User < ActiveRecord::Base
has_many :comments
end
I would like to use the models so that I can return all the users and all comments with text like '%x%'
all_user_comments_about_x = User.comments.about_x
How to proceed?
Thank you