[Ruby] flash message is not displayed in redirect_to

less than 1 minute read


Even if you write as follows, the flash message is not displayed and msg is included in the query parameter.

redirect_to action: :new, alert:'msg'


Describe as follows.

redirect_to({:action => :new} ,{:alert =>'msg'})


redirect_to is used as follows.

redirect_to(options = {}, response_options = {})

If you write like the beginning, the flash message will be treated as the first argument.

redirect_to action: :new, alert:'msg'
redirect_to({:action => :new, :alert =>'msg'}, {})