# Need some help understanding partials, versus authentication

**URL:** <https://www.ruby-forum.com/t/need-some-help-understanding-partials-versus-authentication/136411>\
**Category:** Rails\
**Created:** [May 1, 2008, 8:37pm UTC](https://www.ruby-forum.com/t/need-some-help-understanding-partials-versus-authentication/136411 "2008-05-01T20:37:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhmspector](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/6a8cbe/32.png) [@dhmspector](https://www.ruby-forum.com/u/dhmspector)\
**Post date:** [May 1, 2008, 8:37pm UTC](https://www.ruby-forum.com/t/need-some-help-understanding-partials-versus-authentication/136411/1 "2008-05-01T20:37:29Z")

</div>

Hi,

I am using Rick O.'s restful\_authentication plugin, using  
activefx’s great tutorial ([http://www.railsforum.com/viewtopic.php](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 %\>

 \<% 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) %\> &nbsp; \<%= link\_to 'Change Password', change\_password\_path %\> &nbsp; \<%= link\_to 'Log Out', logout\_url %\> \<% else %\> Username \<%= text\_field\_tag 'login' %\> Password \<%= password\_field\_tag 'password' %\> &nbsp; \<%= submit\_tag 'Log in' %\> Remember me: \<%= check\_box\_tag 'remember\_me' %\> &nbsp \<%= link\_to 'Sign Up', new\_user\_path %\> &nbsp; &nbsp; \<%= link\_to 'Forgot Password?', forgot\_password\_path %\> \<% end %\> \<% end %\>

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](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
