Forum: Ruby on Rails renamed partial won't render?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
65c7c3dd95869e1430a260b049eabd51?d=identicon&s=25 Damian Legassick (dlg)
on 2006-04-30 17:19
hi all

this works

   <%= render :partial => "admin/works/work", :collection =>
@artist.works %>

but this doesn't

   <%= render :partial => "admin/works/worklist", :collection =>
@artist.works %>


even though the partial _work.rhtml and _worklist.rhtml are identical.

worklist.rhtml throws

   undefined local variable or method `work'
    Extracted source (around line #2):

    1: <tr>
    2:   <td><%= link_to work.short_title, :action => 'edit', :id =>
work %></td>

any ideas why?

TIA DLG
65c7c3dd95869e1430a260b049eabd51?d=identicon&s=25 Damian Legassick (dlg)
on 2006-04-30 17:48
no worries, i figured it out


but i'm still struggling with http://www.ruby-forum.com/topic/63930 if
anyone's feeling super-generous.

cheers

dlg
F5c118aaeb5bb7162db613a37e595be8?d=identicon&s=25 Mick Sharpe (micksharpe)
on 2006-04-30 19:51
Partials generate parameter objects based on their names - you need:

    1: <tr>
    2:   <td><%= link_to worklist.short_title, :action => 'edit', :id =>
worklist %></td>


Damian leGassick wrote:
> hi all
>
> this works
>
>    <%= render :partial => "admin/works/work", :collection =>
> @artist.works %>
>
> but this doesn't
>
>    <%= render :partial => "admin/works/worklist", :collection =>
> @artist.works %>
>
>
> even though the partial _work.rhtml and _worklist.rhtml are identical.
>
> worklist.rhtml throws
>
>    undefined local variable or method `work'
>     Extracted source (around line #2):
>
>     1: <tr>
>     2:   <td><%= link_to work.short_title, :action => 'edit', :id =>
> work %></td>
>
> any ideas why?
>
> TIA DLG
65c7c3dd95869e1430a260b049eabd51?d=identicon&s=25 Damian Legassick (dlg)
on 2006-04-30 21:14
thanks Mick
B07c187ac858535358faa9365b66e657?d=identicon&s=25 John Tsombakos (Guest)
on 2006-05-03 18:56
(Received via mailing list)
On 4/30/06, Damian leGassick <damianlegassick@mac.com> wrote:
> @artist.works %>
>     2:   <td><%= link_to work.short_title, :action => 'edit', :id =>
> work %></td>
>
> any ideas why?
>
> TIA DLG

The local variable in the partial is named after the partial. Change it
to:

<%= link_to worklist.short_title, :action => 'edit', :id => worklist %>

jt
This topic is locked and can not be replied to.