Little Things I love about Rails – This Time ActiveRecord

When you are setting a foreign key in an object you can do it using the id directly or through the helper method. In this example comments belong_to users.

# Using an object reference
u = User.get(1234)
c =
c.user = u
# Old school
x =
x.user_id = 1234

Yeah – that is what I like to see – a framework that respects programmer intelligence and gives us choices!