ruby-on-railsadministrate

Rails Administrate gem: How to sort records by 'Published At'?


I'm very much new to the Administrate gem for Ruby on Rails. I can't make it sort/order posts by "Published At". Records seem to be ordered by their id's and not the published_at date, how can I make it work?

See the example app over at Heroku: https://administrate-prototype.herokuapp.com/admin/blog/posts

Thanks in advance


Solution

  • Your looking for Model.order function, here are the docs: https://guides.rubyonrails.org/active_record_querying.html#ordering