Change the model name from Meals
to Meal
Uninitialized Constant In rails
-
12-07-2023 - |
Question
Im getting an uninitialized constant Chef::Meal error when populating my DB.
Am I doing something wrong in my Models?
Chef Model
class Chef < ActiveRecord::Base
has_many :meals
end
Meals Model
class Meals < ActiveRecord::Base
belongs_to :chef
validates :chef_id, presence: true
end
Solution
OTHER TIPS
Your have a Meals
Model, it should be singular i.e, Meal
class Meal < ActiveRecord::Base
belongs_to :chef
validates :chef_id, presence: true
end
Also see these Naming Conventions for Rails
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow