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.
here is what i got..
1) the user creates an account via the restful_authentication gem
2) i have created a table addresses with a user_id field
3) setup the belongs_to has_one relationship
4) after the user autherizes the account they can login and access the
site
5) and complete some forms about them selfs address etc...
what do i need to change when the address get saved to have it get
linked to the account