Forum: Ruby on Rails overriding associations problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8b0f8bf6cd7fbd68f7e3dd5fda0d1133?d=identicon&s=25 lakerhy (Guest)
on 2009-04-30 00:03
(Received via mailing list)
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?
This topic is locked and can not be replied to.