Is there any way to order a list of items through the controller in rails in index ?
Something like
def index
@items = Item.all(order_by :date)
end
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.
Of course there is, and in fact, it’s exactly what you said, except your method calls are off.
Your index view (probably index.html.erb) is looking for an
@itemsarray, right? Well you can format/order/etc that data however you see fit,no problem!