Hey there, I have a problem. class ApplicationController layout :determine_layout def determine_layout "../../public/sites/#{@site.code}/application" end end in rails2.0 this worked, but it was clearly a hack. I tried to fix it in a few ways; 1. symlink public/sites -> app/views/layouts/sites - this breaks because the Dir.glob used to find view files doesnt work for subfolders of a symlink 2. set ApplicationController.view_paths << "public/sites" - this doesnt quite seem to work. 3. manually fix rails and work out the best way to patch it for 2.2.1 - this seemed to work, but isn''t quite plugin-able as a fix mostly I''m wondering, what is the right way to do this? MatthewRudy -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Quite often I''m tasked with doing something very similar. Check out my solution: class ExperiencesController < ApplicationController self.view_paths << File.join(RAILS_ROOT, "cms", "experiences") def show render :layout => "1/layout" end end requiring a folder structure like: RAILS_ROOT/ app/ cms/ experiences/ 1/ layout.html.erb config/ ... Does that help? On Oct 14, 4:25 pm, Matthew Rudy Jacobs <rails-mailing-l...@andreas- s.net> wrote:> Hey there, > I have a problem. > > class ApplicationController > layout :determine_layout > > def determine_layout > "../../public/sites...-NkTKfzR1FWyzQB+pC5nmwQ@public.gmane.org}/application" > end > end > > in rails2.0 this worked, but it was clearly a hack. > > I tried to fix it in a few ways; > > 1. symlink public/sites -> app/views/layouts/sites > - this breaks because the Dir.glob used to find view files doesnt work > for subfolders of a symlink > > 2. set ApplicationController.view_paths << "public/sites" > - this doesnt quite seem to work. > > 3. manually fix rails and work out the best way to patch it for 2.2.1 > - this seemed to work, but isn''t quite plugin-able as a fix > > mostly I''m wondering, > what is the right way to do this? > > MatthewRudy > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Matthew Rudy Jacobs
2008-Oct-15 09:41 UTC
Re: ActionView: render a layout not in app/views?
Andrew Bloom wrote:> Quite often I''m tasked with doing something very similar. Check out my > solution: > > class ExperiencesController < ApplicationController > self.view_paths << File.join(RAILS_ROOT, "cms", "experiences") > > def show > render :layout => "1/layout" > end > end > > requiring a folder structure like: > RAILS_ROOT/ > app/ > cms/ > experiences/ > 1/ > layout.html.erb > config/ > ... > > Does that help? > > On Oct 14, 4:25�pm, Matthew Rudy Jacobs <rails-mailing-l...@andreas-Hey thanks andrew, that''s the same thing I''m trying to achieve, although the code as such won''t quite work in Rails 2.1.1 it''ll give you errors about "found a view path that is not in the right format" the correct way is append_view_path(...) and you pointed out my error I was doing; append_view_path("public/sites") while actually what is required; append_view_path(File.join(Rails.root, "public", "sites")) works great, it seems. Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Matthew Rudy Jacobs
2008-Oct-15 20:19 UTC
Re: ActionView: render a layout not in app/views?
Matthew Rudy Jacobs wrote: tthew Rudy Jacobs <rails-mailing-l...@andreas-> > Hey thanks andrew, > that''s the same thing I''m trying to achieve, > although the code as such won''t quite work in Rails 2.1.1 > > it''ll give you errors about "found a view path that is not in the right > format" > > the correct way is > append_view_path(...) > > and you pointed out my error > > I was doing; > append_view_path("public/sites") > > while actually what is required; > append_view_path(File.join(Rails.root, "public", "sites")) > > works great, it seems. > Thanks.Wrote a quick blog post about this; http://rudygems.com/post/54730156/rendering-layouts-that-live-in-public -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---