Take the 2-minute tour ×

I try to assign to result of rendering an action to an element on page. That should be an easy task but the following statement:

$(".box:first").after("<%= escape_javascript(render :action => "new" ) %>");

will result in the following error message:

ActionView::Template::Error (undefined method `formats' for nil:NilClass):
    1: $(".box:first").after("<%= escape_javascript(render(:action => "new") ) %>");
  • The same code works if i try to render a partial using :partial => "new" (given that the partial with the given name exists)
  • The error message will be the same if I change ':action' f.e. to ':foobar'.

Any ideas what i am doing wrong or is this simple a bug in rails? (3.0.7)

share|improve this question
add comment

2 Answers

It is a bug in your application. Actually it is a bug in your new action in controller

share|improve this answer
add comment

Result of rendering of an action? That's probably not the very best idea. As you said, the code works when you use partial, and that's what you should use. This is from official Rails guides:



share|improve this answer
It should not run any code! It should just render the view for the given action. –  Freya May 10 '11 at 9:22
add comment

Your Answer


