Answer the question
In order to leave comments, you need to log in
How to get the previous post from a specific post in Ruby on Rails???
For example, we know a record with id. So, how can I find the previous entry???
Calculate from the current id-shnik - 1 and find it will not work, since such a record with such an id-shnik can be deleted.
Answer the question
In order to leave comments, you need to log in
.where("id < ?", params[:id]).limit(1)
Only better not id
, a created_at
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question