Can sortable_table plugin do order by multiple columns?
-
28-10-2019 - |
문제
I'm using sortable_table plugin for sorting html table in rails app.
If we want to order by multiple columns, can sortable_table plugin do it ? Example:
select distinct brands.title as brands, models.title as model
from brands, models
where
brands.id = models.brand_id
order by brands.title desc, models.title desc
해결책
Oh.. I get it!
Just put sortable_attributes on controller as array.
For example:
sortable_attributes :brand_model => ["brands.title", "models.title"]
제휴하지 않습니다 StackOverflow