Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

Missing Template errors with rjs

#4197

I have following setup and i am getting missing template errors
class NotesController < ApplicationController

def new

  @note = Note.new
respond_to do |format|
   format.html # new.html.erb
   format.xml  { render :xml => @note }
   format.js
 end

end

new.js.erb
$("#add-notes").after(<%= escape_javascript(render 'form') %>);

Error on the logs
ActionView::Template::Error (Missing partial notes/form with {:formats=>[:js], :locale=>[:en], :handlers=>[:builder, :rjs, :rhtml, :rxml, :erb, :haml]}

Even though there exist this file notes/_form.html.haml i am getting missing template errors when i try to render anything in the rjs file.

Reported by Hemant Patel · March 16th, 2010 @ 09:11 PM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Hemant Patel
    Hemant Patel

    i have to specify the file to render there which works like
    $("#add-notes").after(<%= escape_javascript(render 'form.html.haml') %>);

    i tried to do this in create.js if i am passing an instance it doesnt work, still get template error
    $("#notes").after(<%= escape_javascript(render @note) %>);

    if i specify file there then it works in the create.js too, but i need to pass instance as local variable there
    $("#notes").after(<%= escape_javascript(render 'note.html.haml') %>);

    Is this the new behavior in rails 3 that we would require to specify file names, i hope i have not missed that

    March 16th, 2010 @ 09:45 PM

  2. Hemant Patel
    Hemant Patel
    • Assigned user set to José Valim

    March 16th, 2010 @ 09:46 PM

  3. José Valim
    José Valim
    • State changed from new to resolved

    No, it was a bug. Just fixed!

    March 16th, 2010 @ 10:36 PM

  4. Repository
  5. Hemant Patel
    Hemant Patel

    Now the partials are rendering fine but if i want to render the new template then again its gives missing tempate errors

    $("#notes").after(<%= escape_javascript(render 'new') %>);

    This should render the new template but it gives missing tempate errors

    ActionView::Template::Error (Missing partial notes/new with {:formats=>[:js, :html], :handlers=>[:rxml, :builder, :rjs, :erb, :haml, :rhtml], :locale=>[:en]}

    the render method there just expects to render a partial

    March 16th, 2010 @ 11:18 PM

  6. José Valim
    José Valim
    • Milestone cleared.
    • State changed from resolved to open

    This is odd, it should find the notes/new template. Can you please try to add a failing test case?

    March 16th, 2010 @ 11:20 PM

  7. José Valim
    José Valim
    • State changed from open to resolved

    Oh, I get it. render("new") is invalid in your view. You should do render(:template => "notes/new").

    March 16th, 2010 @ 11:24 PM

  8. Hemant Patel
    Hemant Patel

    hmm.. when i do that the ajax call is doing something weird, the ruby process memory grows infinitely it went up to 6.5GB and my system hanged...

    Dont know whats making the memory to grow so much

    March 17th, 2010 @ 12:22 AM

  9. José Valim
    José Valim

    Can you try to reproduce this error in Rials test suite or in another application? So you can send me and I can investigate further?

    March 17th, 2010 @ 08:33 AM

  10. Jeremy Kemper
  11. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Importance changed from to Low

    Automatic cleanup of spam.

    November 7th, 2010 @ 04:56 PM

  12. Boris
    Boris

    Fixed in
    https://github.com/rails/rails/commit/56fb60ebfe9a20ced1366f3e35b2f...

    And promptly brought back 2 days later
    https://github.com/rails/rails/blob/f28d856cece877d1b2f306f54aeb12c...

    Current problem:
    During AJAX, you cannot render an HTML partial from within a JS partial:

    _new_object.js.erb

    <%= render(@object)) %>

    Fails, will only look for JS.erb not HTML.erb

    Boris

    December 6th, 2010 @ 11:51 AM