Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postgreSql and Rails order

Using PostgreSQL on my Rails application but rails method Order is not working.

    @[email protected]("created_at DESC")

It gives me the same results as

     @[email protected]("created_at ASC")

Using MySQL it's working but in PostgreSQL not working, I am using Rails 3.2.11 and ruby 1.9.3.

like image 906
Remon Amin Avatar asked Apr 14 '26 06:04

Remon Amin


1 Answers

Try this

@comments = @album.comments.order(:created_at) for ascending order

@comments = @album.comments.order(:created_at).reverse_order for descending order

like image 194
muttonlamb Avatar answered Apr 16 '26 19:04

muttonlamb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!