In that case I won't get any user object. Basically I am trying to implement in my application as mentioned here: http://pivotallabs.com/users/nick/blog/articles/272-access-control-permissions-in-rails
For this I have some instance methods in User class. So the 'do_somethin' is basically not optional (only if user is logged in). So as suggested in the article, I am trying to create a null object. I also looked at acts_as_nullobject plugin: http://martincik.com/?p=22 . But it is giving me some errors. Any help/suggestions are welcome. bill walton wrote: > Hi Carlos, > > On Sat, 2009-03-14 at 21:30 +0100, Carlos Santana wrote: > >> My objective is to avoid nil object errors when no user is logged in - >> i.e. when session[:user] is nil. >> >> However, I still need to call some instance methods on this object. >> >> Please suggest me how can I do this? > > I'm thinkin' I must be missin' somethin'. Why can't you use... > > do_somethin' unless session[:user].nil? > > ? > > Best regards, > Bill -- 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 -~----------~----~----~----~------~----~------~--~---

