How can I chain metasearchs’ search method ?
@result = User.search(params[:search]).search(params[:filters])
We can call chain method on ActiveRecord like
User.active.male.where( age: 14..20)
its chaining is possible on meta search’s result ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I got it working.. If you had the same problem, you can try following.
The search method of
meta_searchreturnsMetaSearch::Search::ModelNamewhereModelNameis the name of your model. Meta_search provides a methodrelationfor this object. You can callrelationmethod to get anActiveRecord::Relationobject and then you can call the search method again on that object. See the code below to see what I am exactly talking about.Here
@resultis the instance ofMetaSearch::Search::Userso we can callrelationmethod to get an instance ofActiveRecord::Relationi.eand then we can call search method again on this instance. i.e