I am following the hartl tutorial to build my app, but I had not use User as my model but Guide.
now I'm in the chapter 9.2.1 when I link to the edit_path, the wrong is resulted:
ActionController::ParameterMissing in GuidesController#edit
and the aplication trace is
app/controllers/guides_controller.rb:42:in
guide_params' app/controllers/guides_controller.rb:29:in
edit'
my guides_controller.rb is
class GuidesController < ApplicationController
before_action :signed_in_guide, only: [:edit, :update, :index]
before_action :correct_guide, only: [:edit, :update]
def index
@guides = Guide.all
end
def new
@guide = Guide.new
end
def show
@guide = Guide.find(params[:id])
end
def create
@guide = Guide.new(guide_params)
if @guide.save
# successful
guide_sign_in @guide
flash[:success] = "guide signup success!"
redirect_to @guide
else
flash[:success] = "guide signup failed!"
render 'new'
end
end
def edit
@guide = Guide.find(params[:id])
if @guide.update_attributes(guide_params)
flash[:success] = "Profile updated"
redirect_to @guide
else
render 'edit'
end
end
private
def guide_params
params.require(:guide).permit(:name, :email,
:password, :password_confirmation)
end
def signed_in_guide
unless guide_signed_in?
store_location
redirect_to guidesignin_url, notice: "Please sign in."
end
end
def correct_guide
@guide = Guide.find(params[:id])
redirect_to(root_url) unless current_guide?(@guide)
end
end
I don't understand why the params will missing... Could anyone help me? thanks a lot!