#138 ✓moved_to_github
c00lryguy

:remember_me option not saving with UserSession.new

Reported by c00lryguy | July 11th, 2009 @ 03:53 AM

View

- if current_user
  %p= "Signed in as " << current_user.email << "!"
  %p= current_user_session.remember_me?
- else
  %h1 Login
  %p
    - form_for :login_info, :url => login_path do |f|
      = f.label :email
      = f.text_field :email
      = f.label :password
      = f.password_field :password
      = f.submit "Submit"
      = f.check_box :remember_me
      = f.label :remember_me

Controller

class UserSessionsController < ApplicationController
  before_filter :require_no_user, :only => :create
  before_filter :require_user, :only => :destroy
  
  def create
    user_session = UserSession.new(params[:login_info])
    if user_session.save
      flash[:notice] = "Logged in!"
      redirect_to home_path
    else
      flash[:error] = "Error: Login unsuccessful!"
      redirect_to home_path
    end
  end
  
  def destroy
    current_user_session.destroy
    flash[:notice] = "Logged out!"
    redirect_to home_path
  end
end

Problem

Now when I login with the option 'Remember me?' checked, Rails passes:

Processing UserSessionsController#create (for 127.0.0.1 at 2009-07-11 03:39:15) [POST]
  Parameters: 
  {"commit"=>"Submit", "action"=>"create", "controller"=>"user_sessions", 
  "login_info"=>{"password"=>"[FILTERED]", "remember_me"=>"1", "email"=>"c00lryguy@gmail.com"}}

But the View displays:

Signed in as c00lryguy@gmail.com!
false

No matter how hard I try I can't get the current_user_session to remember the remember_me option.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.

Pages