thanks! works like a charm :) On 17 okt, 01:41, David Kahn <[email protected]> wrote: > On Sat, Oct 16, 2010 at 8:33 AM, mattyh88 <[email protected]> wrote: > > Hi, > > > I'm trying to setup the Authlogic gem. I've followed this tutorial: > > (because I'm using Rails 3) > >http://www.logansbailey.com/2010/10/06/how-to-setup-authlogic-in-rail... > > > All of this works. But now I'd like to render the login form as a > > partial on every page of my site. > > > 1) I've rendered the partial in my application.html.erb file as > > followed: > > > <%= render :partial => "user_sessions/form" %> > > > 2) When I start my server and try rendering my index view of my home > > controller, I get the following error: > > > undefined method `model_name' for NilClass:Class > > Extracted source (around line #1): > > 1: <%= form_for(@user_session) do |f| %> > > 2: <% if @user_session.errors.any? %> > > 3: <div id="error_explanation"> > > 4: <h2><%= pluralize(@user_session.errors.count, "error") %> > > prohibited this user_session from being saved:</h2> > > > 3) I figured out I had to make a new @user_session var in the action > > method of my controller for every view I'd like to render my login > > form partial on. > > > 4) I've put @user_session = UserSession.new in the "new"-action-method > > in my home controller and so my index view rendered fine. But now I'd > > like to render my login form on every page of my site. > > > Is there a way to set the @user_session for every action? Like in the > > application_controller? How would you do that? > > You should able to do this in the application_controller: > > before_filter :new_user_session > > private > > def new_user_session > @new_user_session = UserSession.new > end > > Try that, should then have the @new_user_session available to you since all > controllers inherit from application controller. > > > > > > > Thank you, > > Mathew > > > -- > > 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]<rubyonrails-talk%2Bunsubscrib > > [email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.
-- 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.

