dhmspector
2008-May-01 18:36 UTC
Need some help understanding partials, versus authentication..
Hi, I am using Rick Olson''s restful_authentication plugin, using activefx''s great tutorial (http://www.railsforum.com/viewtopic.php? id=14216) which works well but I am trying to understand how to use partial to modify the workings a bit. What I want to do is rather than have the user click on a link to get to a logjn screen, have the username/password/submit form/controls to be on the home page. What I did was break the login form out into a partial "/app/views/ session/_login_form.html.erb) like so: <% form_tag session_path do %> <div id="UserInfoBox"> <% if logged_in? %> Logged in as: <%= link_to h(current_user.login.capitalize), user_path(current_user) %> <%= link_to ''Edit Profile'', edit_user_path(current_user) %> <%= link_to ''Change Password'', change_password_path %> <%= link_to ''Log Out'', logout_url %> <% else %> <label for="login">Username</label> <%= text_field_tag ''login'' %> <label for="password">Password</label> <%= password_field_tag ''password'' %> <%= submit_tag ''Log in'' %> <label for="remember_me">Remember me:</label> <%= check_box_tag ''remember_me'' %> <span class="userinfobox-links">   <%= link_to ''Sign Up'', new_user_path %> <%= link_to ''Forgot Password?'', forgot_password_path %> </span> <% end %> <% end %> </div> I''m using an application template to allow me to have a common style, etc for all my pages; the conditional code here shows the login form items if you''re not logged in; if you are logged in it shows your user name a a couple of links to edit your profit, change your password, etc. It''s in controllers/views/layout/application.html.erb . On this common template, I call the partial like this: <%= render :partial => "/sessions/login_form", :locals =>{:login => "login", :password =>"password" } %> Everything shows up ok, but when I click the login button, I get sent to the old login template (i.e., the one you''d get to if you went to http://localhost:3001/session/new ) which of course, since I am using am app template, shows up on the body area of the template.. and the user isn''t logged in. Is there something basic I am not getting about how to use a partial to get a user logged in this way..? Any advice would be appreciated! _David --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---