Rails:设置临时变量?

发布于 2024-10-06 05:34:55 字数 255 浏览 0 评论 0原文

我需要为视图设置一个临时变量(实际上更多的是“true”或“false”)。

用例是,当创建用户时,他们会被重定向到仪表板页面。对于 Google AdWords 转化跟踪,需要在视图中显示一些代码,但仅应在运行 create 方法后显示。

所以我猜测解决这个问题的方法是设置一些临时变量(@show_conversion或其他东西)并将其设置为一个视图(类似于闪存消息)。

那么,我该怎么做呢?

I need to set a temporary variable (actually more of a "true" or "false") for a view.

The use case is that when a user is created, they are redirected to a dashboard page. For Google AdWords conversion tracking, there is a bit of code that needs to be displayed in the view, but it only should be displayed after the create method has been run.

So I'm guessing the way to solve that is to set some temp variable (@show_conversion or something) and set it for one view (similar to a flash message).

So, how do I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温暖的光 2024-10-13 05:34:55
<% unless @user.new_record? %>
<!-- do stuff in here -->

<% end %>
<% unless @user.new_record? %>
<!-- do stuff in here -->

<% end %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文