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?
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
#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
fixed
changed my :grouped named_scope to distinct:
named_scope :distinct, :select => "distinct locations.*"