と呼ばれるレールのモデルとcampaign
、別のモデルがありますexport
class Campaign < ActiveRecord::Base
has_one :export
end
class Export < ActiveRecord::Base
belongs_to :campaign
end
それから私はコードを持っています:
if campaign.export.nil?
campaign.create_export(:tag => 'newtag')
end
campaign.export
このコードは常にエクスポート用の新しい行を何度も作成しますnil
。
export by を作成した理由はcampaign.create_export()
、campaign.export
まだnil
.