mysql - Using :include and :conditions creates big queries? -
i want fetch posts commented specifc user eager loading of creator,editor,comments , forum.
post.rb
named_scope :list_of_post {|user_id| { :include => [:creator,:editor,:comments,:forum], :conditions => ["comments.user_id = ?",user_id] } }
but named scope creates big query instead of small in queries creator,editor,comments , forum.
this happening because of using :include , :conditions together.
any solutions returns in queries each instead of 1 big query.
i assume you're using rails 2 instead of scope :
post.find(:conditions => {:id => user.comments.map(:post_id)}, :include => [...])
when migrate rails 3, @ squeel , ransack. requests easier.
Comments
Post a Comment