When selecting either RHTML or RXML template in a respond_to block, I intuitively expect RJS and RXML templates to be rendered as they are. However, it doesn''t work that way. Layout associated with the action is always included. After some head-scratching I got around it by creating a bogus action and rendering its view, like this: def index respond_to |format| do format.rhtml format.xml { render :template => ''index_xml.rxml'', :layout => false } end end private def index_xml raise "This is not a valid action, just a workaround for rendering index.xml without layout, don''t use it" end instead of def index respond_to |format| do format.rhtml format.xml end end This sucks. Generally, "no layout" seems like a reasonable default for RJS and RXML templates to me. I have yet to see anyone using those things with a layout, so the current behavior usually results in extra code to switch it off. Thoughts? Sorry if this was discussed before. Alex --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 3/6/07, Alexey Verkhovsky <alexey.verkhovsky@gmail.com> wrote:> > > Generally, "no layout" seems like a reasonable default for RJS and RXML > templates to me. I have yet to see anyone using those things with a layout, > so the current behavior usually results in extra code to switch it off. > Thoughts?RXML isn''t just for feeds and data dumps - people use it for XHTML, also. But I agree with you that RJS responses shouldn''t have implicit layout. Maybe we should teach respond_to about this: include a template only for the main response (usually HTML), but implicitly turn of layout for others. People could then explicitly choose a layout for them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
There's an @@exempt_from_layout variable in ActionController, which is supposed to exempt rjs by default, but I believe it doesn't work. I haven't been able to get it working in my applications. I think there's an open ticket (or possibly a recently closed one) for it. Andrew On 3/6/07, Mislav Marohnić <mislav.marohnic@gmail.com> wrote:> On 3/6/07, Alexey Verkhovsky <alexey.verkhovsky@gmail.com> wrote: > > > > Generally, "no layout" seems like a reasonable default for RJS and RXML > templates to me. I have yet to see anyone using those things with a layout, > so the current behavior usually results in extra code to switch it off. > Thoughts? > > RXML isn't just for feeds and data dumps - people use it for XHTML, also. > But I agree with you that RJS responses shouldn't have implicit layout. > > Maybe we should teach respond_to about this: include a template only for the > main response (usually HTML), but implicitly turn of layout for others. > People could then explicitly choose a layout for them. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
I use format.js for rjs. On Mar 6, 7:05 am, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> On 3/6/07, Alexey Verkhovsky <alexey.verkhov...@gmail.com> wrote: > > > > > Generally, "no layout" seems like a reasonable default for RJS and RXML > > templates to me. I have yet to see anyone using those things with a layout, > > so the current behavior usually results in extra code to switch it off. > > Thoughts? > > RXML isn''t just for feeds and data dumps - people use it for XHTML, also. > But I agree with you that RJS responses shouldn''t have implicit layout. > > Maybe we should teach respond_to about this: include a template only for the > main response (usually HTML), but implicitly turn of layout for others. > People could then explicitly choose a layout for them.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
OK, RJS is not a problem, and there may be a case where RXML with layout makes sense (does that happen often enough to make it a good default? I doubt). I still say that formatting something with RXML without layout should not require creating a bogus action. It just doesn't feel right. How about format.xml :layout => nil Alex On 3/7/07, carlos.okada@gmail.com <carlos.okada@gmail.com> wrote:> > > I use format.js for rjs. > > On Mar 6, 7:05am, "Mislav Marohnić" <mislav.maroh...@gmail.com> > wrote: > > On 3/6/07, Alexey Verkhovsky <alexey.verkhov...@gmail.com> wrote: > > > > > > > > > Generally, "no layout" seems like a reasonable default for RJS and > RXML > > > templates to me. I have yet to see anyone using those things with a > layout, > > > so the current behavior usually results in extra code to switch it > off. > > > Thoughts? > > > > RXML isn't just for feeds and data dumps - people use it for XHTML, > also. > > But I agree with you that RJS responses shouldn't have implicit layout. > > > > Maybe we should teach respond_to about this: include a template only for > the > > main response (usually HTML), but implicitly turn of layout for others. > > People could then explicitly choose a layout for them. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 7, 1:52 pm, "Alexey Verkhovsky" <alexey.verkhov...@gmail.com> wrote:> I still say that formatting something with RXML without layout should not > require creating a bogus action. It just doesn''t feel right.Are you using Rails 1.2.2? Did you try exempt_from_layout :rxml in your controller? Dan Manges --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> Are you using Rails 1.2.2?Yes Did you try exempt_from_layout :rxml in> your controller?No. And I hear what you say. :) Alex --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
exempt_from_layout works for you with rjs? rjs is supposed to be exempt by default, but I've never got it working. In my app I have this in my application controller to remove layout for rjs... layout lambda { |controller| controller.request.xhr? ? nil : 'main' } If I change that to just... layout 'main' My rjs actions still return a layout. Even if I add "exempt_from_layout :rjs" Maybe I misunderstand this method. :/ On 3/7/07, Alexey Verkhovsky <alexey.verkhovsky@gmail.com> wrote:> OK, RJS is not a problem, and there may be a case where RXML with layout > makes sense (does that happen often enough to make it a good default? I > doubt). > > I still say that formatting something with RXML without layout should not > require creating a bogus action. It just doesn't feel right. How about > > format.xml :layout => nil > > Alex > > > > On 3/7/07, carlos.okada@gmail.com < carlos.okada@gmail.com> wrote: > > > > I use format.js for rjs. > > > > On Mar 6, 7:05am, "Mislav Marohnić" < mislav.maroh...@gmail.com> > > > > wrote: > > > On 3/6/07, Alexey Verkhovsky <alexey.verkhov...@gmail.com> wrote: > > > > > > > > > > > > > Generally, "no layout" seems like a reasonable default for RJS and > RXML > > > > templates to me. I have yet to see anyone using those things with a > layout, > > > > so the current behavior usually results in extra code to switch it > off. > > > > Thoughts? > > > > > > RXML isn't just for feeds and data dumps - people use it for XHTML, > also. > > > But I agree with you that RJS responses shouldn't have implicit layout. > > > > > > Maybe we should teach respond_to about this: include a template only for > the > > > main response (usually HTML), but implicitly turn of layout for others. > > > People could then explicitly choose a layout for them. > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 3/8/07, Andrew Kaspick <akaspick@gmail.com> wrote:> > exempt_from_layout works for you with rjs? rjs is supposed to be > exempt by default, but I''ve never got it working.Check the unit tests. If there are none for this, maybe it''s time to write some new ones --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 3/8/07, Mislav Marohnić <mislav.marohnic@gmail.com> wrote:> > Check the unit tests.Did I say "unit"? I meant functional. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---