n00b to rails here, working on my first project...i have LoginGenerator up and running, and i would like it to display certain site content only when logged in...something like...: <% if logged_in -%> <a href="#" title="admin">Admin section</a> <% end -%> has anybody done this with LoginGenerator?..any help is appreciated.... --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> <% if logged_in -%> > <a href="#" title="admin">Admin section</a> > <% end -%> > > has anybody done this with LoginGenerator?..any help is appreciated....You can find more documentation on this in the readme_login file created when you use the generator. but just a very simple way to do it is: <% unless @session[''user''].nil? %> <a href="/logout">Logout</a> <% end %> Get it? the link won''t display unless someone is logged in. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
A small syntax correction, but using @session is discouraged now, since it is accessing the session variable directly. Just using session[''user''].nil? is the preferred way, since it uses the session method (which right now only wraps the variable, but in the future could potentially do other things). Hope that helps, Tyler Prete> > > You can find more documentation on this in the readme_login file created > when you use the generator. but just a very simple way to do it is: > > <% unless @session[''user''].nil? %> > > <a href="/logout">Logout</a> > > <% end %> > > > Get it? the link won''t display unless someone is logged in. > > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thanks for info guys, its much appreciated...i did get it to work using this, as this is for a blog and there will only be one admin user...seems pretty similiar to your solution, Jon...: <code> <% if @session[''user''].blank? %> not logged in <% else %> logged in, welcome! <% end %> </code> tyler, thanks for info on @session.... --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---