Now that controllers can have multiple view paths I''ve been playing with themes over the weekend. Running into a view issues. I have a before_filter in the ApplicationController that calls prepend_view_path to add the path of my theme. I even log the view_paths in an after_filter to make sure it made it all the way through. The output looks something like: /path/to/rails_project/themes/default/views:/path/to/rails_project/app/views Yet nothing loads. In the docs it says calling prepend_view_path as an instance method will only effect the current request, which I figured should be fine. But I tried calling it as a class method as well, which is supposed to not effect the current request, but all future requests. Even this isn''t working as expected. Only way I''ve managed to get it to work is if I don''t ever clean it up. So I keep prepending over and over, making the path ridiculously long and redundant. I even installed the darwinweb.net multisite plugin. Same issues. Only way I could get it to work is if I removed the code that cleaned up after itself, so the path got out of control. Right now I''m running this with webrick locally on Leopard 10.5. Is this just a Leopard bug or am I maybe doing something wrong? Here is what''s in my before_filter: prepend_view_path(RAILS_ROOT + ''/themes/default/views'') Also tried: ActionController::Base.prepend_view_path(RAILS_ROOT + ''/themes/default/views'') When printed to the log, the paths look great. Any suggestions? -- 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 -~----------~----~----~----~------~----~------~--~---
There''s a view_paths accessor method. If you log view_paths does that show your results as you expect them? On Dec 23, 2007, at 1:15 PM, Eric Jensen wrote:> > Now that controllers can have multiple view paths I''ve been playing > with > themes over the weekend. Running into a view issues. I have a > before_filter in the ApplicationController that calls > prepend_view_path > to add the path of my theme. I even log the view_paths in an > after_filter to make sure it made it all the way through. The output > looks something like: > > /path/to/rails_project/themes/default/views:/path/to/rails_project/ > app/views > > Yet nothing loads. In the docs it says calling prepend_view_path as > an > instance method will only effect the current request, which I figured > should be fine. But I tried calling it as a class method as well, > which > is supposed to not effect the current request, but all future > requests. > Even this isn''t working as expected. Only way I''ve managed to get > it to > work is if I don''t ever clean it up. So I keep prepending over and > over, making the path ridiculously long and redundant. > > I even installed the darwinweb.net multisite plugin. Same issues. > Only > way I could get it to work is if I removed the code that cleaned up > after itself, so the path got out of control. > > Right now I''m running this with webrick locally on Leopard 10.5. Is > this just a Leopard bug or am I maybe doing something wrong? > > Here is what''s in my before_filter: > > prepend_view_path(RAILS_ROOT + ''/themes/default/views'') > > Also tried: > > ActionController::Base.prepend_view_path(RAILS_ROOT + > ''/themes/default/views'') > > When printed to the log, the paths look great. Any suggestions? > -- > 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 -~----------~----~----~----~------~----~------~--~---
Steve Ross wrote:> There''s a view_paths accessor method. If you log view_paths does that > show your results as you expect them?Yes. I do think in the after_filter to make sure it is there for the entire page render. logger.info "soa paths: " + view_paths.join(":") logger.info "soa paths: " + ActionController::Base.view_paths.join(":") Both of those output: /path/to/rails_project/themes/default/views:/path/to/rails_project/app/views Which is perfect. My themes directory comes up before the normal one. -- 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 -~----------~----~----~----~------~----~------~--~---
Well, it sounds like the code you should be looking at is in ActionView, and depending on how fresh your version of Rails is, I''d be looking in base.rb at the render_file method. Whenever something like this stumps me, I use logger.debugs just like you are -- if you want to go one more step, try ruby-debug and step through the render sequence to find out exactly how your template is being located. Sorry not to be of much help here. On Dec 23, 2007, at 9:35 PM, Eric Jensen wrote:> > Steve Ross wrote: >> There''s a view_paths accessor method. If you log view_paths does that >> show your results as you expect them? > > Yes. I do think in the after_filter to make sure it is there for the > entire page render. > > logger.info "soa paths: " + view_paths.join(":") > logger.info "soa paths: " + > ActionController::Base.view_paths.join(":") > > Both of those output: > > /path/to/rails_project/themes/default/views:/path/to/rails_project/ > app/views > > Which is perfect. My themes directory comes up before the normal one. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Steve Ross wrote:> Well, it sounds like the code you should be looking at is in > ActionView, and depending on how fresh your version of Rails is, I''d > be looking in base.rb at the render_file method. Whenever something > like this stumps me, I use logger.debugs just like you are -- if you > want to go one more step, try ruby-debug and step through the render > sequence to find out exactly how your template is being located. > > Sorry not to be of much help here.Was running Rails 2.0.1, but upgraded to 2.0.2 to see if it fixed this. You gave me another direction to look, so I thank you for that. I generally don''t have to dig into Rails this deep, so I don''t know a lot of the internals as well as I would like. -- 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 -~----------~----~----~----~------~----~------~--~---
After lots of debugging I found that the fix was incredibly simple and obvious. I was putting the code in a before_filter block and for some reason that doesn''t work. Maybe scope issues. But if I put the prepend right after the class declaration, it works just fine. Even putting it in a function to be used by a before filter seems to work, as long as the function remains in the ActionController scope. -- 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 -~----------~----~----~----~------~----~------~--~---