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 :
<ul class="avmenu">
<%= render( :partial => ''page/menu'',
:collection => @menupages
) %>
</ul>
partial :
<li>
<%= link_to( ''Link'', { :action =>
''view'', :id => @menupage },
:class => "current" ) %>
</li>
and the result HTML:
<ul class="avmenu">
<li>
<a href="/page/view"
class="current">Link1</a>
</li>
<li>
<a href="/page/view"
class="current">Link1</a>
</li>
</ul>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On 8 Dec 2007, at 19:48, Gady Sujo wrote:> > 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! > > partial : > <li> > <%= link_to( ''Link'', { :action => ''view'', :id => @menupage }, > :class => "current" ) %> > </li>The item of the collection being iterated over is menupage, not @menupage (which is nil) Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 8 Dec 2007, at 19:48, Gady Sujo wrote: > >> </li> > The item of the collection being iterated over is menupage, not > @menupage (which is nil) > > FredThanks 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 ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 8 Dec 2007, at 20:23, Gady Sujo wrote:> > Frederick Cheung wrote: >> On 8 Dec 2007, at 19:48, Gady Sujo 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>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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---