I have a model in my Rails app that uses the :class_name
attribute for has_one
:
class Foo < ActiveRecord:Base
has_one :main_bar, :class_name => "Bar"
# ...
end
I'm a bit unsure what to put in the migration for this class now. Can I use references? What will Rails be looking for as the column name for :main_bar
? Can I do it like this?
class CreateFoos < ActiveRecord::Migration
def self.up
create_table :foos do |t|
t.references :main_bar
end
end
def self.down
drop_table :foos
end
end
Thanks!