Phi*_*lip 1 ruby variables ruby-on-rails
我一直在尝试在创建帖子时出现的flash通知中添加一个变量 #{variable}
但我必须遗漏一些东西,因为我收到的唯一信息是"#{variable}".
这是我的控制器:
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
Run Code Online (Sandbox Code Playgroud)
我一直在尝试使用@participants作为变量,但是,除了消息中的实际"#{@ participant}"之外,我什么都得不到.
我猜您在参与者表单中填写邮件,请尝试:
email = params[:participant][:mail]
Run Code Online (Sandbox Code Playgroud)
而""不是写它''