From 34326af1d44be1c17fb8208578b25d7162a118fe Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 9 Aug 2018 12:00:23 -0400 Subject: Conditionally use `helper_method` in Flash concern I was attempting to use the `flash` functionality in a `Metal` controller. When including the `flash` concern I received the following error: NoMethodError: undefined method `helper_method'.... Either: - `AbstractController::Helpers` should be a dependency of `ActionController::Flash` - `ActionController::Flash` should not require the existence of `AbstractController::Helpers`. Since my use case (set a flash and redirect) has no need for the helper method and that is a common use case, making the dependency conditional seemed the better option. NOTE: This is similar to issue #21067 only the error is within Rails itself while that issue had the error within Devise. --- actionpack/test/controller/flash_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index 34bc2c0caa..a4330897cf 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -342,6 +342,14 @@ class FlashIntegrationTest < ActionDispatch::IntegrationTest end end + def test_flash_usable_in_metal_without_helper + assert_nothing_raised do + Class.new ActionController::Metal do + include ActionController::Flash + end + end + end + private # Overwrite get to send SessionSecret in env hash -- cgit v1.2.3