Note that there are some explanatory texts on larger screens.

plurals
  1. POrender :update gives MissingTemplate error
    primarykey
    data
    text
    <p>I'm trying to get a non-model form_for to reload if the validation fails. The page containing the form (app/views/sites/devices.html.erb) contains the code to load the form as a template</p> <pre><code>&lt;div id="site-device-form"&gt; &lt;%= render partial: "shared/site_device_form", locals: {site: @site, site_device: @site_device} %&gt; &lt;/div&gt; </code></pre> <p>and the form then appears inline as a rendered partial:</p> <pre><code>&lt;%= form_for(:site_device, :url =&gt; {:controller=&gt;"site_devices", :action=&gt;"create"}) do |f| %&gt; &lt;tr&gt; &lt;%= f.hidden_field :site_id, :value =&gt; site.id %&gt; &lt;!-- etc --&gt; &lt;/tr&gt; &lt;% end %&gt; </code></pre> <p>so the form is initially instantiated from the SitesController page, but as it creates a SiteDevice, the form calls the SiteDevicesController#create method to create the page.</p> <p>SiteDevice has some validation code - so what if it fails. I'm trying to get the page to reload, so the form code simply redisplays (we will get the errors shown once the redisplay works)</p> <pre><code> if @site_device.save flash[:notice] = 'SiteDevice was successfully created.' format.html { redirect_to(@site_device) } else #re-render form format.html { render(:update) do |page| page[:site-device-form].replace_html partial: 'shared/site_device_form' end } end </code></pre> <p>Based on my understanding, render(:update) should render the block, passing in the page template. But what I get is an ActionView::MissingTemplate error:</p> <pre><code>ActionView::MissingTemplate (Missing template site_devices/update, application/update with {:locale=&gt;[:en], :formats=&gt;[:html], :handlers=&gt;[:erb, :builder, :coffee]}. Searched in: * "/home/ruby/frontier_development/Frontier/app/views" </code></pre> <p>Any ideas what is going wrong here? How do I get the render to :update the div-id based on the partial I have given it</p> <p>Thanks,</p> <p>Steve</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload