Ok.. Still working on this stuff.. I've got the t.reference in the migration 
for the address class and moved the belongs_to and has_one in the model classes 
as indicated (I didn't notice that!).

I noticed in the association-basics that I should be putting a create_table 
function (if that's what
it's called) in the CreateUsers class for Migrations but I'm concerned about 
doing that since I'll be using the address class on more than just the 'users' 
class -- does it really belong there or ??  
Perhaps I'm overthinking this.. ??

Below are the two class definitions for both the model & migration :

class Address < ActiveRecord::Base
  belongs_to :user
  belongs_to :organization
  belongs_to :supplier
end

class CreateAddresses < ActiveRecord::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.references : users

      t.timestamps
    end
  end

  def self.down
    drop_table :addresses
  end
end

=================================
class User < ActiveRecord::Base
  enum_attr :accountType, %w(regular admin site_admin), :init=>:regular
  
  has_one :name
  has_one :address
  has_one :organization
  
end

class CreateUsers < ActiveRecord::Migration
  
  def self.up
    create_table :users do |t|
      t.boolean  :acctLocked
      t.integer  :familyId
      t.boolean  :isProfileSetup
      t.datetime :lastLogin
      t.string   :password
      t.string   :securityQ
      t.string   :securityA
      t.string   :username
      t.enum     :accountType

      t.timestamps
    end
    
    create_table :a
  end

  def self.down
    drop_table :users
  end
end

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