Just to followup if you're interested, .... the error msg from the op
was due to the fact that the call to session[:user_id] returned nil,
and thus calling find(nil) resulted in that error being raised.  If
you wanted to avoid such an error and just have the find call return
nil if not found, one way is to just call find_by_id:

$ ./script/console

>> u = User.find(nil)
ActiveRecord::RecordNotFound: Couldn't find User without an ID
  from /usr/lib/ruby/...
  ...

>> u = User.find_by_id(nil)
=> nil

Jeff

On Apr 29, 2:10 pm, Stephen Fagan <rails-mailing-l...@andreas-s.net>
wrote:
> Rick Lloyd wrote:
> > Try
>
> > def is_logged_in?
> >   @logged_in_user = User.find(session[:user]) if session[:user]
> > end
>
> > On Apr 29, 10:15 am, Stephen Fagan <rails-mailing-l...@andreas-s.net>
>
> Thanks Rick. It worked a treat and also opened up a couple of gaping
> holes aswell (which I've managed to rectify!)
>
> Cheers
>
> Stephen.
>
> --
> Posted viahttp://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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to