4

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?

Kingsley Simon
  • 2,090
  • 5
  • 38
  • 84
  • See if this answer helps you : https://stackoverflow.com/a/34951198/755421 – bitsapien May 29 '17 at 11:37
  • Possible duplicate of [Rails 5: unable to retrieve hash values from parameter](https://stackoverflow.com/questions/34949505/rails-5-unable-to-retrieve-hash-values-from-parameter) – bitsapien May 29 '17 at 11:38

1 Answers1

5

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
Gerry
  • 10,337
  • 3
  • 31
  • 40