# Stop rendering a response in the default layout

**URL:** <https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537>\
**Category:** rubyonrails-talk\
**Created:** [March 17, 2009, 3:10pm UTC](https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537 "2009-03-17T15:10:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tashfeen\_Ekram](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tashfeen\_Ekram](https://discuss.rubyonrails.org/u/Tashfeen_Ekram)\
**Post date:** [March 17, 2009, 3:10pm UTC](https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537/1 "2009-03-17T15:10:07Z")

</div>

I am trying to follow this tutorial here by Ryan :

> **[\#136 jQuery - RailsCasts](http://railscasts.com/episodes/136-jquery)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

it is a AJAX tutorial on using jquery and expecting the response to be in the form of javascript that will be acted upon by the browser. however, i am getting the response to be rendered in the default layout. i am getting the appropriate response but the js is embedded in HTML and thus not execuuted. is there a way to turn the rendering off for certaini cases?

thanks, tashfeen

---

<div class="post-metadata">

**Author:** ![David\_Knorr1](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@David\_Knorr1](https://discuss.rubyonrails.org/u/David_Knorr1)\
**Post date:** [March 17, 2009, 3:21pm UTC](https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537/2 "2009-03-17T15:21:17Z")

</div>

Rails should really not use the layout unless it's an HTML request. Let me ask you something: Did you accidentally call the view create.html.erb instead of create.js.erb? Remember, the name of a view is separated in three parts by dots: The first one is the name of your action (in this case "create"), the second one is the format (in this case it should be "js" to avoid embedding the output in the layout), the third is the template language (in this case "erb" or embedded Ruby, but it could also be "haml", "builder", "rjs" or whatever suits the need of that specific view).

And then if you are sure that the view is correctly named: What version of Rails do you use? You can find out by looking in your environment.rb file.

---

<div class="post-metadata">

**Author:** ![Tashfeen\_Ekram](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tashfeen\_Ekram](https://discuss.rubyonrails.org/u/Tashfeen_Ekram)\
**Post date:** [March 17, 2009, 5:52pm UTC](https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537/3 "2009-03-17T17:52:11Z")

</div>

here is the js that i am using for the request. does it not make a js request? [http://pastie.org/418937](http://pastie.org/418937)

here is my controller:

[http://pastie.org/418941](http://pastie.org/418941)

then i am using create.js.erb for the response...

---

<div class="post-metadata">

**Author:** ![Tashfeen\_Ekram](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tashfeen\_Ekram](https://discuss.rubyonrails.org/u/Tashfeen_Ekram)\
**Post date:** [March 17, 2009, 6:36pm UTC](https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537/4 "2009-03-17T18:36:18Z")

</div>

i am using rails 2.3.0.

---

<div class="post-metadata">

**Author:** ![Tashfeen\_Ekram](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tashfeen\_Ekram](https://discuss.rubyonrails.org/u/Tashfeen_Ekram)\
**Post date:** [March 17, 2009, 6:39pm UTC](https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537/5 "2009-03-17T18:39:36Z")

</div>

here is specifically what i get in my firefox debug window:

syntax error \<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n

---

<div class="post-metadata">

**Author:** ![David\_Knorr1](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@David\_Knorr1](https://discuss.rubyonrails.org/u/David_Knorr1)\
**Post date:** [March 20, 2009, 8:28pm UTC](https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537/6 "2009-03-20T20:28:30Z")

</div>

Well, if you are sure that:

1) You have correctly named the view "create.js.erb" 2) You don't have a layout called something like "application.js.erb"

... I have really have no clue what's going on here. I suggest you try to upgrade the application to the latest version of Rails, and if that doesn't fix it, I'ld be more than happy if you zipped the app and uploaded it somewhere, so I could take a closer look.

---

<div class="post-metadata">

**Author:** ![Matt\_Jones](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Matt\_Jones](https://discuss.rubyonrails.org/u/Matt_Jones)\
**Post date:** [March 21, 2009, 6:57pm UTC](https://discuss.rubyonrails.org/t/stop-rendering-a-response-in-the-default-layout/40537/7 "2009-03-21T18:57:35Z")

</div>

That's your problem right there - 2.3.0 (the first RC) had issues with template handling on javascript requests. See these tickets:

[http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2052](http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2052)[http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1844](http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1844)

Upgrading to 2.3.2 will fix this.

--Matt Jones
