#650 ✓invalid
Kieran P

Multiple belongs_to only uses one

Reported by Kieran P | March 2nd, 2010 @ 12:42 AM

Consider this Projects model:

fields do
  name :string, :required, :unique
end
belongs_to :client
belongs_to :creator, :class_name => "User", :foreign_key => :id
belongs_to :manager, :class_name => "User", :foreign_key => :id

Then run

script/generate hobo_migration

The resulting SQL for this table

create_table :projects do |t|
  t.string   :name
  t.text     :notes
  t.datetime :created_at
  t.datetime :updated_at
  t.integer  :client_id
  t.integer  :id
end
add_index :projects, [:client_id]
add_index :projects, [:id]

Note, only used client_id. No creator_id or manager_id

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages