Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default sort versions with papertrail

I'm using the paper_trail gem in my Rails 4 application and I want to set a default sort order. papertrail doesn't have a model, only a controller and an initializer.

Where can I put it? Do I have to create a model for it?

default_scope order('created_at DESC')
like image 406
Ossie Avatar asked Dec 02 '22 19:12

Ossie


1 Answers

There's also the reorder command.

http://apidock.com/rails/ActiveRecord/QueryMethods/reorder

versions.reorder('created_at DESC')

It will replace any prior ordering, thus ignoring Papertrail's pre-defined order.

like image 118
Dave T Avatar answered Jan 01 '23 07:01

Dave T