From 1b70b6ee9351681800e10627411ef9e71be0220f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=B6gel?= <100707419+jankoegel@users.noreply.github.com> Date: Tue, 25 Jul 2023 11:50:54 +0200 Subject: [PATCH] Fix flash message. (#125) Before: > flash.inspect => #, @flashes={"allow_other_host"=>false, "flash"=>{"error"=>"Sorry, that was too quick! Please resubmit."}}, @now=nil> `flash[:error]` is empty and the error message only accessible as `flash.to_h.dig("flash", "error")`. Whereas when I manually set `flash[:error]` in Rails, the flash looks like this: #, @flashes={"error"=>"AAAA"}, @now=nil> --- lib/invisible_captcha/controller_ext.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/invisible_captcha/controller_ext.rb b/lib/invisible_captcha/controller_ext.rb index b19b769..2c72e90 100644 --- a/lib/invisible_captcha/controller_ext.rb +++ b/lib/invisible_captcha/controller_ext.rb @@ -30,7 +30,8 @@ def on_timestamp_spam(options = {}) if action = options[:on_timestamp_spam] send(action) else - redirect_back(fallback_location: root_path, flash: { error: InvisibleCaptcha.timestamp_error_message }) + flash[:error] = InvisibleCaptcha.timestamp_error_message + redirect_back(fallback_location: root_path) end end