To go along with my other subject topics like Ruby, Ember, and Git every time I have to look up something Rails related I’d like to get in the habit of adding it to this topic so that I have a quick reference to refer to in the future.


I thought it was .order_by, but it is just .order and looks like this:

User.order(email: :desc)


In your views you can use link_to like this to generate a url:

<%= link_to(wh.workout.name, workout_path(wh.workout)) %>

has_one :through Association

A has_one :through association sets up a one-to-one connection with another model. This association indicates that the declaring model can be matched with one instance of another model by proceeding through a third model.

RSpec Response Url

I was trying to verify what the url of a response was and you need to use response.location because an rspec response object doesn’t have a url.

Testing instance variables in controller/request specs

Testing what instance variables are set by your controller is a bad idea. That’s grossly overstepping the boundaries of what the test should know about. You can test what cookies are set, what HTTP code is returned, how the view looks, or what mutations happened to the DB, but testing the innards of the controller is just not a good idea. - dhh