Erol,
Thanks for that snippet. This is what I made of it:

def maintain_session
    if session[:user_id]
      @current_user = User.find(session[:user_id])
    end
  end

Otherwise an error occurs before login.

Ramon,

I don't understand yet how this will apply to both the FormsController and
ElementsController.

On Sat, Sep 20, 2008 at 12:49 PM, Erol Fornoles <[EMAIL PROTECTED]>wrote:

>
> On Sep 20, 5:09 pm, "Commander Johnson" <[EMAIL PROTECTED]>
> wrote:
> > Hi,
> > When users are logged in, they should always have a 'Logout' function
> handy
> > somewhere.
> >
> > Users control Forms and Elements using two controllers, FormsController
> and
> > ElementsController.
> >
> > What at least works is to add the following lines to the end of both
> layout
> > files.
> >
> > views/layouts/elements.erb.html and
> > views/layouts/forms.erb.html
> >
> > <hr />
> > <%= link_to "Logout #{User.find(session[:user_id]).name}", :controller =>
> > 'admin', :action => 'logout' %>
> > </body>
> > </html>
> >
> > This gives me two issues.
> >  - I'm putting business logic in the View.
> >  - I'm putting this line across two files.
> >
> > CmdJohnson
>
> I agree with Ramon. Also, I suggest you put the following in your
> application.rb:
>
> before_filter :maintain_session
>
> protected
>
> def maintain_session
>  @current_user = User.find(session[:user_id])
> end
>
> That way, you can do this on your layout:
>
> <%= link_to "Logout [EMAIL PROTECTED]", :controller =>
> 'admin', :action => 'logout' %>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to