RailsCasts Pro episodes are now free!

Learn more or hide this

Robert's Profile

GitHub User: robmc

Comments by Robert

Avatar

This took me a while to figure out as well. You want to add the session line to your users controller and point it wherever you are taking your users once they log in.

ruby
  def create
    @user = User.new(params[:user])
    if @user.save
      session[:user_id] = @user.id
      redirect_to some_path, :notice => "Signed up!"
    else
      render "new"
    end
  end
Avatar

I tried to add the cookie line because I would like to automatically log in after signup as well but I am getting the error:

NoMethodError in UsersController#create

undefined method `auth_token' for #< User:0x9a89d60 >

Am I missing something?