# Partials

**URL:** <https://www.ruby-forum.com/t/partials/122528>\
**Category:** Rails\
**Created:** [December 8, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/partials/122528 "2007-12-08T20:48:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gadys](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5e925/32.png) [@gadys](https://www.ruby-forum.com/u/gadys)\
**Post date:** [December 8, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/partials/122528/1 "2007-12-08T20:48:02Z")

</div>

Hi  
I’m trying to render a partial but i recive an unexpected result.  
why isn’t the id of the menupage isn’t generated in the link ?  
Thanks!

here is the code :  
controller :

```
@menupages = @site.pages
@menupages = Page.find(:all)
render :layout => @templatename

```

rhtml :

  
\<%= render( :partial =\> ‘page/menu’, :collection =\> @menupages  
) %\>  

partial :

-   
\<%= link\_to( ‘Link’, { :action =\> ‘view’, :id =\> @menupage },  
:class =\> “current” ) %\>  

and the result HTML:

- [Link1](https://www.ruby-forum.com/page/view)
- [Link1](https://www.ruby-forum.com/page/view)

---

<div class="post-metadata">

**Author:** ![gadys](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5e925/32.png) [@gadys](https://www.ruby-forum.com/u/gadys)\
**Post date:** [December 8, 2007, 8:54pm UTC](https://www.ruby-forum.com/t/partials/122528/2 "2007-12-08T20:54:49Z")

</div>

On 8 Dec 2007, at 19:48, Gady S. wrote:

> ```
> </li>
> 
> ```

The item of the collection being iterated over is menupage, not  
@menupage (which is nil)

Fred

---

<div class="post-metadata">

**Author:** ![gadys](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5e925/32.png) [@gadys](https://www.ruby-forum.com/u/gadys)\
**Post date:** [December 8, 2007, 9:23pm UTC](https://www.ruby-forum.com/t/partials/122528/3 "2007-12-08T21:23:40Z")

</div>

Frederick C. wrote:

> On 8 Dec 2007, at 19:48, Gady S. wrote:
> 
> > ```
> > </li>
> > 
> > ```
> 
> The item of the collection being iterated over is menupage, not  
> @menupage (which is nil)
> 
> Fred

Thanks  
I tried to change the line to :  
\<%= link\_to( ‘Link1’, { :action =\> ‘view’, :id =\> menupage }, :class =\>  
“current” ) %\>

but all i got is :  
undefined local variable or method `menupage’ for  
#\<#Class:0x4713e74:0x4713e4c\>

what am I doing wrong ?

---

<div class="post-metadata">

**Author:** ![gadys](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b5e925/32.png) [@gadys](https://www.ruby-forum.com/u/gadys)\
**Post date:** [December 8, 2007, 9:42pm UTC](https://www.ruby-forum.com/t/partials/122528/4 "2007-12-08T21:42:28Z")

</div>

On 8 Dec 2007, at 20:23, Gady S. wrote:

> Thanks  
> I tried to change the line to :  
> \<%= link\_to( ‘Link1’, { :action =\> ‘view’, :id =\> menupage }, :class  
> =\>  
> “current” ) %\>
> 
> but all i got is :  
> undefined local variable or method `menupage’ for  
> #\<#Class:0x4713e74:0x4713e4c\>

Oops i’d assumed your partial was called menupage, which it isn’t.  
It’s called menu, so that’s the name of the local variables.

Fred
