¿Puede el complemento Sortable_Table hacer ordenar por varias columnas?
-
28-10-2019 - |
Pregunta
Estoy usando complemento sortable_table Para clasificar la tabla HTML en la aplicación Rails.
Si queremos ordenar por varias columnas, ¿puede Sortable_Table Plugin hacerlo? Ejemplo:
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
Solución
¡Oh ya entiendo!
Simplemente coloque Sortable_Attributes en el controlador como matriz.
Por ejemplo:
sortable_attributes :brand_model => ["brands.title", "models.title"]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow