Frage

I would like my users to select the columns of table they want to view. I have read through some code but do not understand how to user ransacker. How can i set the select through a custom ransacker?

ransacker :columns do |parent|
....        
end
War es hilfreich?

Lösung

The way to go is to use the attribute_fields or the attribute_select form helper inside your search form. Checkout the advanced code example on Github, which does something similar, adding select boxes for the fields you want to search on.

Custom ransackers are used to make special searches over several columns and tables, and you have to define them in Arel.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top