# Overriding associations problem

**URL:** <https://www.ruby-forum.com/t/overriding-associations-problem/166833>\
**Category:** Rails\
**Created:** [April 30, 2009, 12:03am UTC](https://www.ruby-forum.com/t/overriding-associations-problem/166833 "2009-04-30T00:03:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lakerhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e19adc/32.png) [@lakerhy](https://www.ruby-forum.com/u/lakerhy)\
**Post date:** [April 30, 2009, 12:03am UTC](https://www.ruby-forum.com/t/overriding-associations-problem/166833/1 "2009-04-30T00:03:18Z")

</div>

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?
