简体   繁体   中英

Render a partial from within a partial?

I have a complex form so I'd like to split it into manageable sections. Problem is that render is throwing an error.

structure:

>app
  >views
   >quote
     _form.html.erb
       >forms
         _contact_form.html.erb
         _products_form.html.erb
          . . .

Inside of _form.html.erb I have the following:

<%= render partial: '/forms/contact_form' %>

And I get: ActionView::MissingTemplate error.

What is the best way to modularize a large form/view to make it manageable? And if I can't render a partial from within a partial; how should it be done?

fixed typo

I meant this: <%= render partial: '/forms/contact_form' %> doesn't work (_ removed)

You should be able to render a partial from partial without any problems.

This is how to render a partial with the proper path:

  • <%= render partial: 'quote/forms/contact_form' %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM