title: Rails: rendering the js.erb template using the controller
body: <p>I have a rails app trying to incorporate some AJAX where clicking new opens a modal window and a form.  I want to be able to display the validation errors if it fails so in my create action, i thought about re-rendering the new.js.erb file.  Is this the right approach?</p>
  
  <pre><code>def create
      @place = Place.new(params[:place])
      if @place.save
         redirect_to places_path, :notice =&gt; "Successfully created place"
      else
         render "new.js.erb"
      end
  end
  </code></pre>
  
  <p>The result I get is escaped js text in my browser like:</p>
  
  <pre><code>$("#new_grouping").html("&lt;div class=\"modal-header\"&gt;\n  &lt;a class=\"close\" data-   dismiss=\"modal\"&gt;×&lt;\/a&gt;\n  &lt;h3&gt;Create a new menu section&lt;\/h3&gt;\n&lt;\/div&gt;\n&lt;form accept-charset=\"UTF-8\" action=\"/places/1-mama-s-pizza/groupings\" class=\"simple_form new_grouping\" id=\"new_grouping\" method=\"post\" novalidate=\"novalidate\"&gt;
  </code></pre>
  
  <p>I've tried putting various options into the render block but no luck.  Any tips?</p>