gpt4 book ai didi

ruby-on-rails - Rails-闪光[:alerts] not showing

转载 作者:数据小太阳 更新时间:2023-10-29 09:01:05 26 4
gpt4 key购买 nike

我想打印一条简单的消息作为提醒,就像在用户写完他的电子邮件后点击订阅按钮一样。

您的电子邮件已保存,我们很快就会联系您进行测试!

这是我的观点:

<form action="/welcome/subscribe" date-remote="true">
<div>
<div id="bottomm">
<input id="bottom" type="text" name="email" placeholder="email" />
</div>
<div>
<input type="submit" value="Ok" class="fit" />
</div>
<%= alert %>
</div>
</form>

这是我的 Controller 中的订阅方法:

def subscribe
@test = Test.new
@test.email = params['email']
@test.save
redirect_to root_url, notice: "Your email is saved, you'll be contacted for a beta very soon!"
end

但是没有任何显示。我在堆栈中看到一些人遇到与我相同的问题,但我尝试了解决方案但没有奏效。

我尝试过这些,但没有一个对我有用。

flash.keep
flash[:notice] = "..."
flash.now[:notice] = "..."
flash[:alert] = "..."
flash.now[:alert] = "..."
and redirecting after

最佳答案

你在 application.html.erb 或者你的 Root View 中是否有 block 来实际显示 flash,像这样:

<% if notice.present? %>
<p><%= notice %></p>
<% end %>

如果不是,那可能是问题所在。

关于ruby-on-rails - Rails-闪光[:alerts] not showing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35629954/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com