Rails アプリに次の:class_name
属性を使用するモデルがありますhas_one
。
class Foo < ActiveRecord:Base
has_one :main_bar, :class_name => "Bar"
# ...
end
現在、このクラスの移行に何を入れるべきか少しわかりません。参考書は使えますか?Rails は の列名として何を探し:main_bar
ますか? 私はこのようにすることができますか?
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
ありがとう!