LoginGenerator: show content only if logged in

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 -%>
Admin section
<% end -%>

has anybody done this with LoginGenerator?..any help is appreciated…

<% if logged_in -%>
Admin section
<% 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? %>

Logout

<% end %>

Get it? the link won’t display unless someone is logged in.

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 P.

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…:

<% if @session['user'].blank? %> not logged in <% else %> logged in, welcome! <% end %>

tyler, thanks for info on @session