This project is archived and is in readonly mode.
Detached Mongrel server renders no layout
Reported by Mislav | January 27th, 2009 @ 12:25 PM
Detached Mongrel server cannot seem to find an implicit layout and therefore renders actions without a layout.
This is a regression from commit 858a420c.
I narrowed it down to this method:
# action_controller/layout.rb
def layout_list
  Array(view_paths).sum([]) { |path| Dir["#{path}/layouts/**/*"] }
end
With detached Mongrel this method returns an empty array because the current working dir is "/" (root), but Path#to_s returns a relative path since it strips RAILS_ROOT from the beginning (why?!).
The fix is this glob:
Dir["#{path.path}/layouts/**/*"]
I haven't been able to produce a failing test. I tried something like:
# this test simulates a detached Mongrel server
def test_application_layout_is_found_with_absolute_paths
  old_load_paths = ProductController.view_paths
  begin
    Dir.chdir("/") do
      ProductController.view_paths = [ File.dirname(__FILE__) + '/../fixtures/layout_tests/' ]
      @controller = ProductController.new
      get :hello
      assert_equal 'layout_test.rhtml hello.rhtml', @response.body
    end
  ensure
    ProductController.view_paths = old_load_paths
  end
end
but I seem to be on the wrong track, I just keep getting unrelated errors and can't really get an action to render without a layout.
Comments and changes to this ticket
- 
        

josh January 27th, 2009 @ 03:29 PM
- Milestone cleared.
 - State changed from new to open
 
 - 
        

Repository January 27th, 2009 @ 05:06 PM
- State changed from open to resolved
 
(from [a1ac635d9655cd26f86593263c3e9b956d330141]) Ensure the full path is used when searching for layouts [#1803 state:resolved] http://github.com/rails/rails/co...
 
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
Tags
Referenced by
- 
        
          1803 
          Detached Mongrel server renders no layout
        (from [a1ac635d9655cd26f86593263c3e9b956d330141]) Ensure ...