0

ROR でデータベースをシードしようとすると、次のエラーが発生します。

[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
rake aborted!
undefined method `merchant_category' for #<Merchant:0x227c12e0>
/home/boris/Desktop/Wholetail/db/seeds.rb:18:in `block in <top (required)>'
/home/boris/Desktop/Wholetail/db/seeds.rb:15:in `<top (required)>'
Tasks: TOP => db:seed

( --trace を指定してタスクを実行すると、完全なトレースが表示されます)

商人モデル:

class Merchant < ActiveRecord::Base

    has_many :deals
    has_many :customers
    has_many :mmcs
    has_many :merchant_categories, through: :mmcs

    validates :merchant_name, presence: true
    validates :merchant_email, presence: true, uniqueness:true
    validates :merchant_phone, presence: true
    validates :merchant_address, presence: true
    validates :merchant_url, presence: true, uniqueness: true
    validates :merchant_category, presence: true

end

マーチャント カテゴリ モデル:

class MerchantCategory < ActiveRecord::Base
    has_many :mmcs
    has_many :merchants, through: :mmcs

    validates :merchant_category_name, presence: true, uniqueness: true

end
4

1 に答える 1

1

Merchant と Merchant Categories の間にあるためhas_many、 を使用することはできませんmerchant_category。である必要がありますmerchant_categories

于 2014-03-08T06:41:04.753 に答える