2

いくつかのネストされた属性を持つレコードを作成しようとしていますが、ネストされた属性はポリモーフィック モデルにあります。このようなもの:

class Office < ActiveRecord::Base
  attr_accessible :name, :description, :address_attributes

  has_one :address, as: :location_data_source

  accepts_nested_attributes_for :address
end

class Shop < ActiveRecord::Base
  attr_accessible :name, :description, :address_attributes

  has_one :address, as: :location_data_source

  accepts_nested_attributes_for :address
end

class Address < ActiveRecord::Base
    attr_accessible :street, :city

    belongs_to :location_data_source, polymorphic: true
end

そして、次のようなレコードを作成したいと思います。

o = Office.create(:name = 'The Big Office', description = 'a really big office' :address_attributes => [:street => 'main street', :city => 'No Name City'])

しかし、「with_indifferent_access」エラーが発生します。

NoMethodError: メソッド `with_indifferent_access' が未定義です...

エラーの意味がよくわからないので、苦労していると思います。何か案は?

4

0 に答える 0