Searchlogic cannot sort search result
Imagine a code:
search = Project.search(
:title_or_description_or_child_name_or_child_age_or_inspiration_or_decorating_style_or_favorite_item_or_others_like_any => keys,
:galleries_id_like_any => @g,
:styles_id_like_any => 开发者_Python百科@st,
:tags_like_any => @t
)
search.all returns the rows correctly.
But search.descend_by_views returns nil.
Is this gem buggy? What else should I use then?
I'm not sure why it's not working with search.descend_by_views
but this should work:
search = Post.descend_by_views.search(
:title => ...
...
)
Instead of search, you could also use scopes for everything else too:
Post.title_or_anything_like_any(keys).galleries_id_like_any(@g)...descend_by_views.all
精彩评论