Search code examples
ruby-on-rails-4authlogic

Unable to save user password with authlogic


I am using Authlogic in rails4, and i have replaced the encrypt_password field with password.

  <div class="field">
    <%= f.label :password %><br>
    <%= f.password_field :password %>
</div>
<div class="field">
    <%= f.label :password_confirmation %><br>
    <%= f.password_field :password_confirmation %>
</div>


class User < ActiveRecord::Base

  attr_accessor :password, :password_confirmation

  acts_as_authentic do |c|
    #c.validate_password_field = false
  end

end

The problem is i am unable to save password other fields are being saved if i'll disable the c.validate_password_field else getting Password is too short (minimum is 4 characters), that means it's not accepting the password but why ?

can anyone help ?


Solution

  • I got the solution.

    actually i forgot to allow password in user_params. rails4 new feature strong parameters.

    def user_params
        params.require(:user).permit(:username, :subdomain, :email, :password, :password_confirmation, :persistence_token, :authentication_token)
      end