dimanche 12 avril 2015

Sort array in view

I am trying to sort an array in the view by using link_to's, however I'm not getting any changes in the results.


The view -



= link_to 'Rating', sort: "rating"
= link_to 'Origin', sort: "origin"
= link_to 'Meal Time', sort: "meal_time"


The controller -



def index
@recipes = Recipe.order(params[:sort])
end


Am I missing something? I was using this ASCIIcast as it's the most simple solution I've found to this problem.


Aucun commentaire:

Enregistrer un commentaire