class Address < ActiveRecord::Base
belongs_to :user
and my tables:
users has has the normal id field… and the addresses has user_id.
do I need a foriegn_key statement?
also the AR docs say the user_id should be automagicly populated…
if I have an account… and I’m logged in and create an address…
should it not get the user_id populated?
No, this is pretty rare. This is usually for odd joins or for legacy
table layouts.
also the AR docs say the user_id should be automagicly populated…
if I have an account… and I’m logged in and create an address…
should it not get the user_id populated?
If you create a new user via some_address.user.new() or
some_address.user.create() then everything will be linked together.