Question

I am working on a scaffold pins rails app. On the app there are three models, pins, users and categories. Initially the pins should show up with the earliest pins at the very bottom, and the latest ones at the very top. However, this order seems to be reversed when the pins are at the users and categories show page, they have the earliest pins at the top and the latest one hid at the bottom.

Looking at my pins model, I do have the below code, it doesn't make sense if I add the below code in to users and categories model.

pin.rb

 find(:all, order: "created_at desc")
Was it helpful?

Solution

In the show action for your users controller and the show action for your categories controller:

@pins = Pin.order("created_at DESC")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top