How to I retrieve the second, third .. entries in a database. I don\'t want to use the auto incrementing id generated by rails.
As I am deleting entries from my data
Model.second
was added to Rails 4.1.8.So you can use it on Rails versions equal to or greater than that.
.third
, .fourth
and .fifth
were also added to ActiveRecord::FinderMethods.
what you need is
#n=2,3,4 etc
.limit(1).offset(n)
Say you want the fourth user:
@users = User.limit(4)
@fourth_user = @users[3]
Concerning your second question, destroy_all
should do the trick since it triggers all callbacks. Be sure to add :dependent => :destroy
in your relationships.