未定义的局部变量或## AuthorsController的方法`author':0x94c5ee8>

I am trying to submit information into a PHP database and I am getting this error.

authors_controller.rb

class AuthorsController < ApplicationController
  def new
    @page_title = 'Add New Author'
    @author = Author.new
  end

  def create
    @author = Author.new(author_params)
    @author.save

    redirect_to authors_path
  end

  def update
  end

  def edit
  end

  def destroy
  end

  def index
  end

  def show
  end

  def author_params 
    params.require(author).permit(:first_name, :last_name)
  end 
end

when I click on submit button the error pops up.

undefined local variable or method `author' for AuthorsController

The error is in your author_params where you have author which is treated as undefined variable. It should be :author(a symbol)

def author_params
  params.require(:author).permit(:first_name, :last_name)
end