im giving searchlogic a try to combine named scopes easily only issue i have is it doesnt return distinct results ive worked around this with a named scope of grouped which selects only the id and groups by the id once ive got the ids, how can i quickly rebuild the object...find(:id=>[@ids]...or something similar? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Conrad Taylor
2010-May-20 19:24 UTC
Re: using searchlogic to retrieve ids, then rebuild object?
On Thu, May 20, 2010 at 11:38 AM, dan <mr.dan.marks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> im giving searchlogic a try to combine named scopes easily > only issue i have is it doesnt return distinct results > ive worked around this with a named scope of grouped which selects > only the id and groups by the id > once ive got the ids, how can i quickly rebuild the > object...find(:id=>[@ids]...or something similar? > >What''s the actual code to your query that uses Searchlogic? This will help other to better assist you. -Conrad> -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
#model location.rb named_scope :grouped, :select => ''locations.id'', :group => ''locations.id'' has_many :criterias, :through => :locations_criterias #controller locations_controller.rb # i havent even gotten to the paginate part yet @locations = Location.criterias_name_or_name_like(@query).grouped #.paginate(:page => params[:page]) the @locations returns multiples of same result so i added the grouped named scope that only selects the id in order to only group on id at this point i need to rebuild my location object using the id returned by @locations -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
fixed changed my :grouped named_scope to distinct: named_scope :distinct, :select => "distinct locations.*" -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.