# Partials - asked before never got reply

**URL:** <https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656>\
**Category:** Rails\
**Created:** [August 15, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656 "2006-08-15T14:13:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [August 15, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656/1 "2006-08-15T14:13:12Z")

</div>

I’m trying to figure out how multiple partials in one page would be  
configured when they are based on some action in the controller.  
As an example -  
I have a main/welcome page. If someone new or a user not logged in  
arrives at this page I display both a registration form and a login  
form. However, if they are logged in then those forms should not show  
up on that page. Also should mention that I have a \_register partial  
and a \_login partial.

Now maybe I just need a seperate page to welcome users who are logged  
in but I want to see if I could do it as described above.  
Right now the welcome.rhtml page is set up like such:

\<% if @u %\> #if user is logged in / session  
\<%= render :partial =\> “main/logout” %\>  
\<%= render :partial =\> “main/session” %\>  
\<%= @c.first\_name %\>  
\<% else %\>  
\<%= render :partial =\> “main/login” %\>  
\<%= render :partial =\> “main/register” %\>  
\<% end %\>

And in the layout:

\<%= render(:partial =\> "logout" )%\> \<%= render(:partial =\> "register" ) %\>

\<%= render(:partial =\> "login" ) %\>

So I think this is all wrong but not sure how to go about  
accomplishing my design.  
Any help / suggestions would be greatly appreciated.

TIA  
Stuart

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656/2 "2006-08-15T14:17:21Z")

</div>

So what exactly is your problem? I can’t quite work that out from the  
post. What are you trying to achieve and why is what you are doing  
currently not working?

Max

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [August 15, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656/3 "2006-08-15T14:19:33Z")

</div>

Hi –

On Thu, 10 Aug 2006, Dark A. wrote:

> in but I want to see if I could do it as described above.
> 
> accomplishing my design.  
> Any help / suggestions would be greatly appreciated.

Don’t put things in the layout unless you want them displayed 🙂

David

–  
[http://www.rubypowerandlight.com](http://www.rubypowerandlight.com) =\> Ruby/Rails training & consultancy  
----\> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! \<-----  
[http://dablog.rubypal.com](http://dablog.rubypal.com) =\> D[avid]A[.]B[lack’s][Web]log  
[Ruby for Rails](http://www.manning.com/black) =\> book, Ruby for Rails  
[http://www.rubycentral.org](http://www.rubycentral.org) =\> Ruby Central, Inc.

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [September 4, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656/4 "2006-09-04T14:45:20Z")

</div>

none

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [September 4, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656/5 "2006-09-04T14:45:27Z")

</div>

Ok, I realized that was my problem but I still need to use  
@content\_for\_layout though

Stuart

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [September 4, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656/6 "2006-09-04T14:45:24Z")

</div>

Is my question just ridiculous , too basic or no one actually knows ?

Stuart

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [September 4, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/partials-asked-before-never-got-reply/64656/7 "2006-09-04T14:45:27Z")

</div>

In your layout just surround the 2 divs with the if statement just like  
you  
did in welcomr.rhtml
