RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: rjstires
For those trying, if have not already, to sort by association or be more specific with which columns can be sorted;
acceptable_cols = ["users.name", "users.email", "addresses.city", "addresses.state"]
acceptable_cols.include?(params[:sort]) ? params[:sort] : "name"
Just specifying an array of the allowed columns, rather than relying on the columns defined by the model allows you better control
I don't know if this is the best solution, I'm about two weeks new to Ruby and RoR.