On 28 July 2011 07:53, 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

The belongs_to definition should be in the model class not the migration.

>
>  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

Ditto for has_one

Colin

-- 
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.

Reply via email to