當試圖更新模型時,我遇到了嚴重的參數錯誤。創建操作有效,更新失敗。Rails 500錯誤 - 強參數
Started PATCH "/companies/6/users/10" for 71....... at 2017-02-21 06:27:27 +0000
Processing by UsersController#update as JS
Parameters: {"company_id"=>"6", "id"=>"10"}
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 9], ["LIMIT", 1]]
SQL (3.6ms) UPDATE "users" SET "last_activity_at" = '2017-02-21 06:27:27.940545' WHERE "users"."id" = $1 [["id", 9]]
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 10], ["LIMIT", 1]]
此錯誤是不是非常有幫助的,至少不是我:(
Completed 400 Bad Request in 12ms (ActiveRecord: 6.1ms)
ActionController::ParameterMissing (param is missing or the value is empty: user):
app/controllers/users_controller.rb:60:in `user_params'
app/controllers/users_controller.rb:43:in `block in update'
app/controllers/users_controller.rb:42:in `update'
控制器PARAMS
def user_params
params.require(:user).permit(:name, :role, :email, :company_id, :password, :password_confirmation, :current_password)
end
我正在使用link_to來修補此記錄。 不知道如何構建以下內容以包含:user用戶參數。 <%= link_to company_user_path(:company_id => current_user.company_id,:id => user),:method =>:patch,remote:true do%><%= render partial:「permission」,locals:{角色:user.role.to_s.upcase}%><% end %> – martinmsf