Just to clarify - are you setting session[:user_id] in the user.login! (session) call? The other suggestions on handling a nil session[:user_id] (i.e. using find_by_id) are the appropriate ways to handle the error.
Eric On Apr 30, 12:09 pm, Stephen Fagan <[email protected]> wrote: > E. Litwin wrote: > > When are you saving the user_id to the session? > > > You need to force a redirect to a login page if there is no session > > [:user_id] and you should also handle the fact that session[:user_id] > > may be nil in your is_logged_in? method. > > Its saved in the login method: > > user = User.find_by_user_name(@user.user_name) > > if user and user.password_matches?(@user.password) > user.login!(session) > if @user.remember_me == "1" > cookies[:remember_me] = { :value => "1", > :expires => 10.years.from_now } > user.authorization_token = Digest::SHA1.hexdigest( > "#{user.user_name}:#{user.password}") > > I have a redirect if someone tries to access the admin privileges if > thats what you mean? > > -- > 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 [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 -~----------~----~----~----~------~----~------~--~---

