If else not working?

Chris Gunnels wrote:

def index
    @oLogin = User.find_by_login(params[:l])
    if @oLogin.login
      @sLoggedInName = @oLogin.login + ", you've logged in successfully"
    else
      render :controller => 'sessions'
    end
  end

Aesthetically, I'd change @oLogin to @user, since User.find... will
return a User instance. I'd also avoid Hungarian notation and camelCase
variable names.

I think the actual problem is that your call to render is wrong. I'm
guessing you want a redirect. You might also want to read up on flash
for messaging to the user. I'd probably write this method something like
this:

def index
  @user = User.find_by_login(params[:l])
  if @user
    flash[:notice] = "#{@user.login}, you've logged in successfully"
  else
    redirect_to :controller => 'sessions', :action => 'new'
  end
end