I am trying to follow this tutorial here by Ryan : http://railscasts.com/episodes/136-jquery 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org
2009-Mar-17 15:21 UTC
Re: Stop rendering a response in the default layout
On 17 Mar., 16:10, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am trying to follow this tutorial here by Ryan :http://railscasts.com/episodes/136-jquery > > 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?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. -- Cheers, David Knorr http://twitter.com/rubyguy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
here is the js that i am using for the request. does it not make a js request? http://pastie.org/418937 here is my controller: http://pastie.org/418941 then i am using create.js.erb for the response... On Mar 17, 11:21 am, "ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org" <ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org> wrote:> On 17 Mar., 16:10, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I am trying to follow this tutorial here by Ryan :http://railscasts.com/episodes/136-jquery > > > 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? > > 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. > > -- > Cheers, > David Knorrhttp://twitter.com/rubyguy--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i am using rails 2.3.0. On Mar 17, 1:52 pm, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> here is the js that i am using for the request. does it not make a js > request?http://pastie.org/418937 > > here is my controller: > > http://pastie.org/418941 > > then i am using create.js.erb for the response... > > On Mar 17, 11:21 am, "ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org" <ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org> wrote: > > > On 17 Mar., 16:10, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I am trying to follow this tutorial here by Ryan :http://railscasts.com/episodes/136-jquery > > > > 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? > > > 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. > > > -- > > Cheers, > > David Knorrhttp://twitter.com/rubyguy--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
here is specifically what i get in my firefox debug window: syntax error <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n On Mar 17, 1:52 pm, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> here is the js that i am using for the request. does it not make a js > request?http://pastie.org/418937 > > here is my controller: > > http://pastie.org/418941 > > then i am using create.js.erb for the response... > > On Mar 17, 11:21 am, "ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org" <ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org> wrote: > > > On 17 Mar., 16:10, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I am trying to follow this tutorial here by Ryan :http://railscasts.com/episodes/136-jquery > > > > 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? > > > 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. > > > -- > > Cheers, > > David Knorrhttp://twitter.com/rubyguy--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org
2009-Mar-20 20:28 UTC
Re: Stop rendering a response in the default layout
On 17 Mar., 19:39, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> here is specifically what i get in my firefox debug window: > > syntax error > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n > > On Mar 17, 1:52 pm, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > here is the js that i am using for the request. does it not make a js > > request?http://pastie.org/418937 > > > here is my controller: > > >http://pastie.org/418941 > > > then i am using create.js.erb for the response...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. -- Cheers, David Knorr http://twitter.com/rubyguy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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/1844 Upgrading to 2.3.2 will fix this. --Matt Jones On Mar 17, 2:36 pm, "tashfeen.ekram" <tashfeen.ek...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i am using rails 2.3.0. >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---