我没有更改我的 users_controller 文件,但现在我在更新用户配置文件“参数数量错误(2 比 1)”后收到此错误。它指向“app/controllers/users_controller.rb:41:in `update'”。
我的代码看起来是正确的,但我必须遗漏一些东西。有任何想法吗?
用户控制器:
class UsersController < ApplicationController
def new
@user = User.new
end
def profile
@profile = User.profile
end
def create
@user = User.new(params[:user])
if @user.save
UserMailer.registration_confirmation(@user).deliver
session[:user_id] = @user.id
redirect_to root_url, notice: "Thank you for signing up!"
else
render "new"
end
end
def show
@user = User.find(params[:id])
end
def edit
@user = User.find(params[:id])
end
def index
@users = User.all
end
def destroy
User.find(params[:id]).destroy
flash[:success] = "User deleted."
redirect_to users_url
end
def update
@user = if current_user.role?(:admin)
User.find(params[:id])
else
current_user
end
if @user.update_attributes(params[:user])
flash[:success] = "Account updated"
redirect_to @user
else
render 'edit'
end
end
end