0
我试图从语法转换searchlogic在我的控制器使用洗劫从轨2.3.5升级后3.2.17转换搜索功能洗劫轨道3
我search_users方法:
def search_users
term = params[:search]
show = Show.find(params[:show_id]) if params[:show_id]
# Get users in show audiences
show_user_ids = show.audiences.map(&:user_ids).flatten
# Remove the users that 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
过时的代码是:
@users = User.first_name_or_last_name_or_company_like(term).id_is(show_user_ids)
first_name_or_last_name_or_company_like
是searchlogic语法,因为我没有它在我的应用程序了,它的定义。我可以使用@users = User.where(...)
并通过term = params[:search]
?
我将如何通过User.where first_name或last_name或公司像术语?
试过:@users = User.where(["first_name = :first_name or email = :email", { first_name: term, email: term }])
及其返回的用户只使用名字进行搜索。
任何帮助将不胜感激!