DhatchXIX DhatchXIX - 2 months ago 8
Ruby Question

Must pass hash error when passing params to devise registration/ sign up

This is the error that is displaying

When assigning attributes, you must pass a hash as an argument.


I am trying to pass params through a URL something like this
/users/sign_up?account=571917355


registrations_controller.rb

def new
@user = User.new(params[:account])
end


Is devise doing something that isn't allowing this to work? I've searched, but nothing out there seems to help fix the error. I'm not even really sure what this error means.

Answer

For Devise new

before_filter :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up).push(:account)
  end

or

devise_parameter_sanitizer.permit(:sign_up, keys: [:account])

More here info