Controller code
def index @people, @klass = case params[:sort] when "by_name" [Person.order(name: :asc), "foo"] else [Person.all, "bar"] end end
Code view
The css class for tr is foo or bar based on the sort parameter:
%tr{class: @klass} %th= link_to "Name", people_path(sort: "by_name"), id: "name-header" %th Date %th Description %th More Info
source share