class User < ActiveRecord::Base
belongs_to :creator, :class_name => 'Admin', :foreign_key
=> :creator_id
end
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.column :name, :string
t.column :creator_id, :string
t.timestamps
end
end
def self.down
drop_table :users
end
end
I override the naming associations by using the :class_name option in
the
belongs_to method. I am expecting that it is assocaited by
the :creato_id in
this case. However the error message shows that it is still looking
for
users.admin_id instead of users.creator_id though I specify the
:foreign_key. How could that be?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---