문제

Is it possible to check if a filter on a search-object from the rails gem meta-search is set? I've got this code in my controller:

@search = Tree.search(params[:search])

when i do @search.search_attributes.empty? i got true if i the form never has been sent. But if i send the form, even if its blank i get false (which is logic)

What is the best solution to check (from the view) if there is no filter active?

I hope someone can help me with this, thanks!

도움이 되었습니까?

해결책

Instead of empty u can check using present.

@search.search_attributes.present?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top