0

我正在使用 Ruby on Rails 3.2.13 和 Ruby 1.9.3。我想在提交表单时显示一个 flash[:notice],但问题是当用户登录时会完美显示 flash 消息,但是当用户未登录并提交此表单时,flash 消息不是显示。

在控制器/创建动作中

if @ticket
  flash[:notice] = "Thank you for contacting LittleCast. We have received your message and it has been routed to concerned department."
  redirect_to new_contact_request_path
else
  render :new
end

在 application.html.erb

<% if flash[:notice].present? %>
  <div class="success-dv"><%= flash[:notice] %></div>
<% end %>
4

0 回答 0