新手。
用脚手架生成的代码,notice可以在前端显示。
redirect_to users_url, notice: 'Succeed.'
<p id="notice"><%= notice %></p>
但是我添加了一个message,就失败了
redirect_to users_url, notice: 'Succeed.', message: 'test'
<p id="notice"><%= notice %></p>
<h1><%= params[:message] %></h1> #不显示
<h1><%= message %></h1> #报错不存在message
PHPz2017-04-25 09:04:06
notice: 'Succeed.' is the parameter of redirect_to. The parameters in params are passed by url. users_url is used to generate url, so your writing method should be
redirect_to users_url(message: 'test'), notice: 'Succeed.'