You don't have a FK for user_id in your ADDRESSES table for starters, and you didn't include your model files, so there's no way of knowing whether you've defined the relationships there.
See: http://guides.rubyonrails.org/migrations.html http://guides.rubyonrails.org/association_basics.html On Thu, Jul 28, 2011 at 8:53 AM, Rick & Nellie Flower <[email protected]>wrote: > Ok.. So I've got my initial table structures setup and I was hoping I could > have associations help me out with something akin to embedded/nested objects > but without the direct nesting (unless there's another way to achieve that > goal).. > > So, I've got an Address class that looks like the following : > > class CreateAddresses < ActiveRecord::Migration > belongs_to :user > > def self.up > create_table :addresses do |t| > t.string :address > t.string :city > t.string :state > t.string :zip > t.string :email > t.string :phone > > t.timestamps > end > end > > def self.down > drop_table :addresses > end > end > ============================ > I've then got a user class that looks like the following : > > class CreateUsers < ActiveRecord::Migration > has_one :address > > def self.up > create_table :users do |t| > t.srting :name > t.boolean :isProfileSetup > t.datetime :lastLogin > t.string :password > t.string :securityQ > t.string :securityA > t.string :username > > t.timestamps > end > end > > def self.down > drop_table :users > end > end > > I was hoping I could do something like the following in the rails console > and have it work > but it does not: > > => @user=User.create > =>@[email protected] > > Any ideas on whether I'm barking up the wrong tree with associations -- > perhaps using > the wrong syntax or is it even possible with what I want to do? I feel > like they ought to work > but… > > Any ideas?? Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

