Rails:设置一个临时变量?

时间:2010-12-07 03:50:49

标签: ruby-on-rails variables temporary

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

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

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

那么,我该怎么做?

1 个答案:

答案 0 :(得分:0)

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

<% end %>