Ruby and Rails: setting current_user if statement <p>I'm in a controller method.</p> <pre><code>p current_user p request.referrer != Rails.application.routes.url_helpers.dashboard_patients_add_url if request.referrer != Rails.application.routes.url_helpers.dashboard_patients_add_url p 'in here' current_user = User.find_by_authentication_token(params[:token])[0] end p current_user </code></pre> <p>Returns </p> <pre><code>#&lt;User id: 33, first_name: "1", last_name: "1", working_at: "1", password_digest: nil, password_confirmation: nil, created_at: "2014-03-20 00:37:54", updated_at: "2014-03-20 00:38:00", email: "aab@gmail.com", encrypted_password: "$2a$10$nw1UHb0PeFUFh17zKRhbsOA.MirNfXW69wj7aRfMSDEw...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2014-03-20 00:37:54", last_sign_in_at: "2014-03-20 00:37:54", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", authentication_token: "HHz6KyqrHF7pC41DyGKH", salutation: "1", speciality: "1", cell_phone_number: "1", office_phone_number: "1"&gt; false nil </code></pre> <p>So the if statement is false and the p within the if statement is not run...which would lead me to believe that current_user should not get set to the User.find_by_authentication_token result. However, clearly, it does. If I comment out the if statement, then I get </p> <pre><code>#&lt;User id: 33, first_name: "1", last_name: "1", working_at: "1", password_digest: nil, password_confirmation: nil, created_at: "2014-03-20 00:37:54", updated_at: "2014-03-20 00:38:00", email: "aab@gmail.com", encrypted_password: "$2a$10$nw1UHb0PeFUFh17zKRhbsOA.MirNfXW69wj7aRfMSDEw...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2014-03-20 00:37:54", last_sign_in_at: "2014-03-20 00:37:54", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", authentication_token: "HHz6KyqrHF7pC41DyGKH", salutation: "1", speciality: "1", cell_phone_number: "1", office_phone_number: "1"&gt; false #&lt;User id: 33, first_name: "1", last_name: "1", working_at: "1", password_digest: nil, password_confirmation: nil, created_at: "2014-03-20 00:37:54", updated_at: "2014-03-20 00:38:00", email: "aab@gmail.com", encrypted_password: "$2a$10$nw1UHb0PeFUFh17zKRhbsOA.MirNfXW69wj7aRfMSDEw...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2014-03-20 00:37:54", last_sign_in_at: "2014-03-20 00:37:54", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", authentication_token: "HHz6KyqrHF7pC41DyGKH", salutation: "1", speciality: "1", cell_phone_number: "1", office_phone_number: "1"&gt; </code></pre> <p>As expected. I have no idea why anything within that if statement would have any impact on anything since its condition is false.</p> <p>I've clearly misunderstood something extra basic, and I'd love for someone to clear my vision.</p>