我一直在尝试在使用 #{variable}
创建帖子时出现的 flash 通知中添加一个变量
但我一定是遗漏了什么,因为我收到的唯一消息是“#{variable}”。
这是我的 Controller :
def create
@participant = Participant.new(params[:participant])
respond_to do |format|
if @participant.save
mail = params[:email]
format.html { redirect_to @participant, notice: 'Thanks, We will be sending out instructions to: #{mail}' }
format.json { render json: @participant, status: :created, location: @participant }
else
format.html { render action: "new" }
format.json { render json: @participant.errors, status: :unprocessable_entity }
end
end
end
我也一直在尝试将@participants 作为变量,但是,除了消息中实际的“#{@participants}”,我仍然没有得到任何东西。
最佳答案
我猜你在参与者表格中填写了邮件,所以试试:
email = params[:participant][:mail]
用""
代替''
关于ruby-on-rails - Rails - 在 flash 通知中传递变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15382306/