This project is archived and is in readonly mode.
Missing Template errors with rjs
Reported by Hemant Patel | March 16th, 2010 @ 09:11 PM | in 3.0.2
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.
Comments and changes to this ticket
-
Hemant Patel March 16th, 2010 @ 09:45 PM
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
-
Hemant Patel March 16th, 2010 @ 09:46 PM
- Assigned user set to José Valim
-
José Valim March 16th, 2010 @ 10:36 PM
- State changed from new to resolved
No, it was a bug. Just fixed!
-
Repository March 16th, 2010 @ 10:36 PM
(from [56fb60ebfe9a20ced1366f3e35b2f9bd0bac8e45]) Fix rendering of HTML partials inside JS templates [#4197 status:resolved] http://github.com/rails/rails/commit/56fb60ebfe9a20ced1366f3e35b2f9...
-
Hemant Patel March 16th, 2010 @ 11:18 PM
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
-
José Valim March 16th, 2010 @ 11:20 PM
- 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?
-
José Valim March 16th, 2010 @ 11:24 PM
- State changed from open to resolved
Oh, I get it. render("new") is invalid in your view. You should do render(:template => "notes/new").
-
Hemant Patel March 17th, 2010 @ 12:22 AM
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
-
José Valim March 17th, 2010 @ 08:33 AM
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?
-
Jeff Kreeftmeijer November 7th, 2010 @ 04:56 PM
- Importance changed from to Low
Automatic cleanup of spam.
-
Boris December 6th, 2010 @ 11:51 AM
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
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Referenced by
- 4197 Missing Template errors with rjs (from [56fb60ebfe9a20ced1366f3e35b2f9bd0bac8e45]) Fix ren...