Allow layout fallback when using `layout` method #3884

Merged
merged 2 commits into from Dec 7, 2011

Conversation

Projects
None yet
3 participants
@sikachu
Member

sikachu commented Dec 7, 2011

Rails will now use your default layout (such as "layouts/application") when you specify a layout with :only and :except condition, and those conditions fail.

For example, consider this snippet:

class CarsController
  layout 'single_car', :only => :show
end

Rails will use 'layouts/single_car' when a request comes in :show action, and use 'layouts/application' (or 'layouts/cars', if exists) when a request comes in for any other actions.


Bonus point: I found out that assert_template :layout => 'blahhhhhh' will returns true regardless of layout that got rendered. I've fixed that as well.

sikachu added some commits Dec 2, 2011

Fix bug in assert_template when using only `:layout` option
Currently if you're do this:

    assert_template :layout => "foo"

Regardless of what layout you were using, the test will always pass. This was broken since the introduction of :layout option in [d9375f3].

We have a lot of test cases in actionpack/test/controller/layout_test.rb that use this feature. This will make sure that those test cases are not true negative.
Allow layout fallback when using `layout` method
Rails will now use your default layout (such as "layouts/application") when you specify a layout with `:only` and `:except` condition, and those conditions fail.

For example, consider this snippet:

    class CarsController
      layout 'single_car', :only => :show
    end

Rails will use 'layouts/single_car' when a request comes in `:show` action, and use 'layouts/application' (or 'layouts/cars', if exists) when a request comes in for any other actions.

josevalim added a commit that referenced this pull request Dec 7, 2011

Merge pull request #3884 from sikachu/master-fix_layout
Allow layout fallback when using `layout` method

@josevalim josevalim merged commit 0df2ef3 into rails:master Dec 7, 2011

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva Jan 6, 2012

Member

Thanks! :) ❤️

Thanks! :) ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment