Flash message not shown after redirected by verify

I have the following snippet in a controller.

verify :params => “post”, :only => [:create, :update, :destroy],
:add_flash => {“notice” => “Invalid Access”}, :redirect_to => {:action
=> ‘list’}

If I directly access /posts/create by typing URL (GET), the program
redirects to the “list” action, but the flash message I added is not
shown in the redirected page.

Any help would be appreciated.

T K wrote:

Any help would be appreciated.

Do you usually get flash messages from other sources? (i.e. do you have
<%= flash[:notice] %> somewhere in your layout?)

http://www.5valleys.com/

http://www.workingwithrails.com/person/8078

T K wrote:

I have the following snippet in a controller.

verify :params => “post”, :only => [:create, :update, :destroy],
:add_flash => {“notice” => “Invalid Access”}, :redirect_to => {:action
=> ‘list’}

I’m pretty sure the proper key is :flash and not :add_flash.

http://api.rubyonrails.com/classes/ActionController/Verification/ClassMethods.html#M000307

Daniel W. wrote:

T K wrote:

I have the following snippet in a controller.

verify :params => “post”, :only => [:create, :update, :destroy],
:add_flash => {“notice” => “Invalid Access”}, :redirect_to => {:action
=> ‘list’}

I’m pretty sure the proper key is :flash and not :add_flash.

http://api.rubyonrails.com/classes/ActionController/Verification/ClassMethods.html#M000307

Ha! Maybe I should read my own links. :slight_smile:

I’ve never seen the add_flash directive. In that case, I dunno.

How/where are you calling flash in your views?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs