Note that there are some explanatory texts on larger screens.

plurals
  1. PORails tutorial 6.3.4 authenticate error
    primarykey
    data
    text
    <p>I'm doing the ruby on rails tutorial book and I have come to an error. I checked everything he wrote and I still get the error. It tells me authenticate is an undefined method for nil:NILclass. I don't know what to do. </p> <p>user.rb:</p> <pre><code>class User &lt; ActiveRecord::Base attr_accessible :email, :name, :password, :password_confirmation attr_accessor :password, :password_confirmation has_secure password before_save { |user| user.email = email.downcase } validates :name, presence: true, length: { maximum: 50 } VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true, format: { with: VALID_EMAIL_REGEX}, uniqueness: {case_sensitive: false} validates :password, presence: true, length:{ minimum: 6 } validates :password_confirmation, presence: true end </code></pre> <p>and (some of) my user_spec.rb</p> <pre><code>before do @user = User.new(name: "Example User", email: "User@example", password: "foobar", password_confirmation:"foobar") end subject { @user } it { should respond_to(:password_digest) } it { should respond_to(:password) } it { should respond_to(:password_confirmation) } it { should respond_to(:authenticate) } it { should be_valid } # USER.PASSWORD describe "when password is not present" do before { @user.password = @user.password_confirmation = " "} it {should_not be_valid} end describe "when password is not present" do before { @user.password_confirmation = "mismatch" } it { should_not be_valid } describe "when password is nil" do before { @user.password_confirmation = nil } it {should_not be_valid} end describe "with a password that's too short" do before { @user.password = @user.password_confirmation = "a" * 5 } it { should be_valid } end describe "return value of authenticate method" do before { @user.save } let(:found_user) { User.find_by_email(@user.email) } describe "with valid password" do it { should == found_user.authenticate(@user.password) } end describe "with invalid password" do let(:user_for_invalid_password) { found_user.authenticate("invalid") } it {should_not == user_for_invalid_password} specify { user_for_invalid_password.should be_false} end end end </code></pre> <p>Thanks alot for all that can help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload