I'm a newbie in Ruby and I'm trying to integrate google re-captcha gem on my Rails application https://github.com/ambethia/recaptcha/.
It works well on localhost, but in production throws this error:
ActionView::Template::Error (undefined method `flash' for Node ID: franchises_form Parent: root Children: 0 Total Nodes: 1:FranchisesFormWidget):
119: </input>
120: </div>
121:
122: <%= recaptcha_tags %>
123:
124: </br><small>bla bla bla</small>
I've been searching on the web, and all the solutions suggest using
config.middleware.use ActionDispacth::Flash
The problem is that I don't really know where to introduce it. I tried at application.rb, at the recaptcha config file, and at FranchisesFormWidget, which calls the gem's methods for displaying the recaptcha form.
In application.rb I've got references to middleware management:
class Refinery::Resources::Engine
initializer 'delete rack cache' do |app|
app.config.middleware.delete Rack::Cache
end
end
class Refinery::Images::Engine
initializer 'delete rack cache' do |app|
app.config.middleware.delete Rack::Cache
end
end
So, for example, I added this:
class FranchisesFormWidget
initializer 'use action dispatch flash' do |app|
app.config.middleware.use ActionDispatch::Flash
end
end
But gives me another error (which I don't remember). What I am doing wrong? What must I do?