Question

I have defined the following strong parameters in my user controller

def user_params
    params.require(:user).permit(:category_id, :nationality_id, :first_name, :last_name, :gender, :date_of_birth, :emailId, :password, :password_confirm, :avatar_url)
  end

The model uses password_registry field for encryption using the rails has_secure_password method.This is the view iteration

<label class= 'sniglet'> Password</label>
                            <%= f.text_field(:password, :class => 'form-control') %>

                            <label class= 'sniglet'> Confirm password</label>
                            <%= f.text_field(:password_confirm, :class => 'form-control') %>

The error that I get on running the app is this

undefined method `password_confirm' for #<User:0x007fcc00042210>

What am I doing wrong.

Was it helpful?

Solution

I managed to fix this issue by declaring attr_accessor methods in the model.

attr_accessor :password
attr_accessor :password_confirm
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top