我尝试过搜索,但是在我的模型中添加了"include MetaSearch::Searches::ActiveRecord“之后,当运行”meta_search (params:search)“时,出现了一个错误"undefined method `joins_values'”。
我认为我不需要全文,所以我认为以下gem现在不适合我的项目::mongoid_fulltext mongoid-sphinx sunspot_mongoid mongoid_search
我尝试了一个名为scoped search的旧gem,我可以让它工作,例如:
get :search do
@search = Notification.scoped_search(params[:search]
search_scope = @search.scoped
defaul_scope = current_user.notifications
result_scope = search_scope.merge defaul_scope
@notifications = result_scope
render 'notifications/search'
end但允许调用我的模型中的任何作用域。
做这项工作有什么“最佳实践”吗?
发布于 2012-04-16 15:39:38
如果你想限制你想在scoped_search上使用的范围,你可以过滤你的参数:搜索如下:
def limit_scope_search
params[:search].select{|k,v| [:my_scope, :other_scope_authorized].include?(k) }
endhttps://stackoverflow.com/questions/10168001
复制相似问题