#26 ✓resolved

Feature Request - new_search to take ActiveRecord options? (Like :include)

Reported by omarvelous | November 16th, 2008 @ 06:19 PM

I recently updated to the gem from a git cloned version of Searchlogic, when it was Searchgasm. I was in that version able to do the following..

@all_people = Person.all :include => {:profile => [:main_photo]}
@search = @all_people.new_search(params[:search])
@people, @people_count = @search.all, @search.count

However now I get the following error: undefined method new_search' for #<Array:0x33c3798>

Ok.... But this (eager loading) is still not supported

@search = Person.new_search(params[:search], :include => {:profile => [:main_photo])
@people, @people_count = @search.all, @search.count

Any chance that this will be implemented?

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson November 16th, 2008 @ 07:15 PM

    • State changed from “new” to “open”

    Hi, try this:

    @search = Person.new_search(params[:search].merge(:include => {:profile => [:main_photo]}))

    new_search only accepts a single hash

    let me know if this works

  • omarvelous

    omarvelous November 16th, 2008 @ 07:24 PM

    No luck...

    With nil params[:search] I get:

    You have a nil object when you didn't expect it!
    The error occurred while evaluating nil.merge

    With params[:search] I get:

    Unknown key(s): include
  • Ben Johnson

    Ben Johnson November 16th, 2008 @ 07:36 PM

    Sorry about that, not thinking today.

    You would need to do:

    (params[:search] || {}).merge()

    But :include is a protected option for new_search, you are going ot have to do:

    @search = Person.new_search(params[:search])
    @search.include = :main_person
  • omarvelous

    omarvelous November 17th, 2008 @ 08:53 AM

    Yea, that did the trick.


  • Ben Johnson

    Ben Johnson November 26th, 2008 @ 03:24 AM

    • State changed from “open” to “resolved”

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket