The browser returned me the following error in Locals # show:
undefined method 'model_name' for NilClass: Class
51: <%= form_for(@food) do |f| %> 52: <%= render 'shared/error_messages', object: f.object %> 53: <div class="field"> 54: <%= f.label :nome %>
Here is my locals_controller.rb (show action)
def show @local = Local.find(params[:id]) @foods = @local.foods.paginate(page: params[:page]) respond_to do |format| format.html
end
And here food_controller.rb (create action)
def create @food = @local.foods.build(params[:food]) if @food.save flash[:success] = "Food created!" redirect_to '/locals' else flash[:error] = "Error on creating food" render '/locals' end end
The product model and local model are associated with: has_many and belongs_to
What is the problem? Thanks you
source share