After I am trying to display a flash message on my contact page. Here is my code
def contact_us
UserMailer.delay.contact_email(params)
flash[:notice] = 'Thanks for contacting us!!!!!'
redirect_to contact_path
end
def contact
end
I tried to access the flash messages but getting a blank response.
[1] pry(#<#<Class:0x0000000aef74f0>>)> flash
=> #<ActionDispatch::Flash::FlashHash:0x0000000a633328 @discard=#<Set: {}>, @flashes={}, @now=nil>
Also tried this solution But getting same issue. Can anyone have an idea why I am getting this issue? How can I fix this issue.
Request details
Redirected to http://localhost:3000/contact
Completed 302 Found in 213ms (ActiveRecord: 46.9ms)
Started GET "/contact" for 127.0.0.1 at 2017-02-23 01:08:43 +0530
EDIT I also tried with
Try1
redirect_to contact_path, notice: 'Thanks for contacting....'
still getting the same issue.
Try 2
flash[:notice] = 'Thanks for contacting....'
flash.keep(:notice)
redirect_to contact_path
still getting the same issue.
Tried all the solutions from flash[:notice] doesn't work with redirect_to still getting the same error.
I am using ruby 2.0.0p643 and Rails 4.0.13.