user3159063
user3159063

Reputation: 375

Undefined method when seeding

I'm getting the following errors when trying to seed my database in 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

(See full trace by running task with --trace)

Merchant Model:

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

Merchant Category Model:

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

    validates :merchant_category_name, presence: true, uniqueness: true

end

Upvotes: 0

Views: 193

Answers (1)

Raj
Raj

Reputation: 22956

Since it is has_many between Merchant and Merchant Categories, you cannot use merchant_category. It should be merchant_categories.

Upvotes: 1

Related Questions