I think it is @oLogin that you need to test for nil before accessing
@oLogin.login. This is to check whether the find returned anything.

2009/3/10 Chris Gunnels <[email protected]>

>
> I have the following action that is supposed to test whether a username
> exists or not. It seems that the first condition never fails. I have put
> nothing in the params[:l] hash and the first condition executes. Any
> ideas?
>
> def index
>    @oLogin = User.find_by_login(params[:l])
>    if @oLogin.login != nil
>      @sLoggedInName = @oLogin.login + ", you've logged in successfully"
>    else
>      render :controller => 'session'
>    end
>  end
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to