Skip to main content

how do i resolve this error?

Ruby • Asked by Alan Morley
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

Hey Alan! 

Change your "book_params" method at the bottom of the controller to "recipe_params" and you should be good. Looks like just a copy-paste typo you missed. 🤓

That's got it. Thanks Chris :-D

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.