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
-
Matt Jones March 3rd, 2010 @ 02:44 AM
- State changed from new to invalid
See my comments on #648. :foreign_key is not used correctly here.
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป