Alan Morley
Joined
110 Experience
0 Lessons Completed
0 Questions Solved
Activity
Posted in Can anyone see the error here?
NameError in RecipesController#new
uninitialized constant RecipesController::Category
def new
@recipe = current_user.recipes.build
@categories = Category.all.map{ |c| [c.name, c.id] } <-- saying this lines wrong
end
def create
Posted in how do i resolve this error?
That's got it. Thanks Chris :-D
Posted in how do i resolve this error?
undefined local variable or method `recipe_params' for #<RecipesController:0x00007ffa3c046490> Did you mean? recipe_path
def create
@recipe = Recipe.new(recipe_params)
if @recipe.save
redirect_to root_path
class RecipesController < ApplicationController
def index
end
def new
@recipe = Recipe.new
end
def create
@recipe = Recipe.new(recipe_params)
if @recipe.save
redirect_to root_path
else
render 'new'
end
end
private
def book_params
params.require(:recipe).permit(:title, :description, :rating, :author)
end
end
def index
end
def new
@recipe = Recipe.new
end
def create
@recipe = Recipe.new(recipe_params)
if @recipe.save
redirect_to root_path
else
render 'new'
end
end
private
def book_params
params.require(:recipe).permit(:title, :description, :rating, :author)
end
end