Have you tried a partial layout? It sounds like what you are looking for.

Thanks,
Bradly

Sent from my iPhone

On Jul 7, 2012, at 11:23 PM, Chris McCann <[email protected]> wrote:

> Okay, so what do I mean by an "inverse partial"?  I've got a situation where 
> I want to wrap the content of multiple views in a single controller with a 
> common form_for block that includes some other HTML markup as well as the 
> Submit button and Cancel link.  I'm trying to find a DRY approach.
> 
> Let's say the controller has three actions: building, rent, and timing.  Each 
> of these provides some form fields to edit a few related attributes of a 
> single model.  I want to use the same form_for block and submit/cancel stuff 
> for each of the three views.  I can't figure out how to effectively wrap the 
> specialized view content for each action with the common form stuff.
> 
> I tried using a _form partial and content_for:
> 
> <% content_for :terms do %>
>     # specific content for each action
> <% end %>
> 
> <%= render :partial => 'form' %>
> 
> Where _form.html.erb is:
> 
> <%= form_for :proposal ... do |f| %>
>     <%= yield :terms
>     <%= f.submit "Save" %>
>     <%= link_to "Cancel" %>
> <% end %>
> 
> This fails, complaining about the reference to the local :f variable in the 
> specific view content.  It seems that content is processed first, not in the 
> context of the _form partial.
> 
> Can anyone recommend an approach that will let me re-use the outer form_for 
> and other mark-up?
> 
> Thanks,
> 
> Chris
> -- 
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to