Search Results

Search found 2 results on 1 pages for 'mustafi'.

Page 1/1 | 1 

  • Rails 2.3: using another models named_scope inside another named_scope

    - 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 How can I add a named_scope to the user model like so class User < ActiveRecord::Base has_many :comments named_scope :comments_about_x, :includes => :comments, :comments_named_scope => :about_x end Which allows me to do all_user_comments_about_x = User.comments_about_x The reasoning is I often need to use the comment models about_x named scope logic but I don't want to have "comments.text like '%x%')" scattered around my code. I hope this make sense :) Thank you

    Read the article

  • 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

    Read the article

1