I have in app/lib/action_dispatch/flash/flash_hash.rb file this code:
class ActionDispatch::Flash::FlashHash def my_method #... end end
but when I call it in controller, I get undefined method 'my_method' for ActionDispatch::Flash::FlashHash:0x007fcf8e81e510:
def index flash.my_method end
Why? Any ideas?
Do you know for sure if that file is being loaded? I think that it should be since it's in app, but I would just want to verify that.
You can also just simply define this in an initializer if you want a simpler way of doing this. It would look something like this:
# config/initializers/flash.rb class ActionDispatch::Flash::FlashHash def my_method #... end end
And last question, what's the goal you're trying to accomplish with this?
Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.