Thanks guys!  I'll play with this some more when I come home this evening.. 

One more question if I could.. If I get the plumbing all plugged in as needed, 
do I ned to do
anything in particular with the view for the address object to get it to show 
up when adding or
editing a user record or will it get pulled in automagically?  Just curious. 
Thanks!

I'm still trying to figure this all out in my head!

On Jul 28, 2011, at 12:43 AM, Chris Kottom wrote:

> 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 <n...@ca-flower.com> 
> 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
> =>@city=@user.address.city
> 
> 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 rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> 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 rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> 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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to