Partials

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:

    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

    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 ?

    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

    This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

    | Privacy Policy | Terms of Service | Remote Ruby Jobs