javascript - Convert search feature from searchlogic to ransack rails 3 -


i'm trying convert syntax searchlogic , use ransack after upgrade rails 2.3.5 3.2.17

my search_users method in controller:

def search_users   term = params[:search]    show = show.find(params[:show_id]) if params[:show_id]    # users in show audiences   show_user_ids = show.audiences.map(&:user_ids).flatten    # remove users have full access     show_user_ids -= show.show_permissions.full.map(&:user_id)      @users = user.first_name_or_last_name_or_company_like(term).id_is(show_user_ids)      render 'shared/search_users'  end 

the outdated code is:

@users = user.first_name_or_last_name_or_company_like(term).id_is(show_user_ids) 

first_name_or_last_name_or_company_like syntax searchlogic , since don't have on app anymore, undefined.

i can use @users = user.where(...) , pass in term = params[:search]?

how pass in user.where first_name or last_name or company term ?

tried: @users = user.where(["first_name = :first_name or email = :email", { first_name: term, email: term }]) , returning users search using first name only.

any appreciated!

i got working, used following code:

@users = user.where(["first_name = :first_name or last_name = :last_name or company = :company", { first_name: term, last_name: term, company: term }]) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -