On Fri, Dec 26, 2008 at 3:15 PM, Clem Rock <[email protected]
> wrote:

>
> Hello,
>    I love the concept of using <%=yield %> to automatically render
> content but there are times where I find it a bit restraining.
>
> For instance, I would like to to use the exact same partial for these 2
> methods:
>
> list_roles and create
>
> If I try to use render :partial => 'list_roles' in the create method,
> the only way I can get it to work is to create a _list_roles.html.erb
> template which seems like a bit of overkill.
>
> The only difference that the create/list_roles template is going to have
> is one extra dynamic table row.
>
> Is there anyway to increase the flexibility of the yield method?
>
> Thanks,
> Clem
>
I'm confused by the juxtaposition of "I would like to use the exact same
partial" and "The only difference is that ..."
But, plowing on ahead... my understanding of render :partial is that it
looks in the view folder associated with the controller for the template.
If #create and #list_roles are in the same folder, you should be able to
create a _list_roles.html.erb template which is referenced by the views for
both the #create and #list_roles actions (via render :partial =>
'list_roles').  The stuff that is identical between the two should go in the
_list_roles.html.erb partial.

So, create.html.erb could look like this:
<%= render :partial => "list_roles" %>

and list_roles.html.erb could look like this:
<%= render :partial => "list_roles" %>
<h1>This is the extra line</h1>

I think I must be misunderstanding your question, since I feel like I just
reiterated your original question.

Anyway, that's my $.02.

--wpd

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to