I’ve got a list of all my articles, ordered by client name.
articles_controller.rb – index
@articles = Article.order('client')
In my show page, how do I get the next and previous article in that order?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you already have the article for the show action, you could use ‘index’ to get the position of this article in the Array returned by ‘Article.order(‘client’).all’
Somehow like this:
Based on this you can calculate the previous and next article simple enough. Not sure if this is the smartest solution, but it should work.