i have this error but not quite sure how to solve it. I have an API version module VI and my usercontroller module is like this
class Api::V1::UsersController < ApplicationController
def register
ap params
end
def user_params
params.require(:user).permit(
:email, :password,:password_confirmation, :username, :name, :fb_id, :picture, :access_token, :reset_password_token,
:sign_in_count, :authenticatable_salt, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip, :last_sign_in_ip
)
end
end
I have a register function and each time i want to log the params, i get an error
ActionController::UnfilteredParameters (unable to convert unpermitted parameters to hash)
Not sure how to solve this given that i have already permitted the attributes for my user model already.
I didnt include the gem strong_parameters but not sure if i have to because i dont think i have to include it.
I know permitting the attributes would have worked for Rails 4 not sure why it is not working for Rails 5. Do i need to do anything on my model as well?
You created the method user_params
, but in the register
action you are using params
(that is, unfiltered parameters).
So change this:
def register
ap params
end
to this:
def register
ap user_params
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.