[rspec-users] Problems with form_for and partials

rupert rupert_apsc at rupespad.com
Sun Oct 21 08:46:53 EDT 2007


> i'm having problem with a form_for situation where i'm trying to DRY
> out the repeated parts of my forms and put them in common/form and
> render the form elements via another partial in controller_name/_form.
> Here's the first form
>
> # app/views/common/form
> <% form_for ... do |f| -%>
>   <%= render :partial => "params[:controller]/form", :object => f %>
>   <p>Submit buttons...</p>
> <% end -%>

I had exactly the same problem and ending up putting the

form_for ...do |f|

in the partial so I didn't have to pass form builders around.  This  
won't be practical though if you are using multiple partials for your  
forms fields.

Rupert



More information about the rspec-users mailing list