I believe this has been brought up a few times before and people came up with different hacky solutions. Now as Rails 3 is touted as modular/decoupled etc. is there a clean way to initiate request (and get response) while serving another request? What are potential pitfalls of doing so? Use cases include making Server Side Includes work with just Rails application (i.e. without third-party like Varnish) which in turn can be used to implement complex caching schemes, sort of a "components" system, or just to delegate work to another controller (sounds like something that should be done with routing but I thinks there are edge cases when you don''t want to get redirection involved). -- 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.
Michael Koziarski
2010-Jun-21 09:47 UTC
Re: Serve request from the inside of another request
> Now as Rails 3 is touted as modular/decoupled etc. is there a clean > way > to initiate request (and get response) while serving another request? > What are potential pitfalls of doing so?We had something similar to this in rails prior to 2.0. You could call render_component and it would create a sub request, process it and return the result. In reality it turned out to be a poor level of abstraction. Rather than: <%= render_component "/posts/sidebar" %> You were better off calling <%= render :partial=>"sidebar" %> It was almost the same in terms of abstraction but the simple rendering system is much much faster than simulating an entire request.> Use cases include making Server Side Includes work with just Rails > application (i.e. without third-party like Varnish) which in turn can > be used to implement complex caching schemes, sort of a > "components" system, or just to delegate work to another controller > (sounds like something that should be done with routing but > I thinks there are edge cases when you don''t want to get redirection > involved).If you really wanted to experiment with full requests rather than just delegating rendering via partials or something similar, you could give rack a try. You can get access to the raw rack env from a request, and then pass that to a new instance of your app. -- Cheers Koz -- 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.