sev*_*ens 3 ruby-on-rails dev-to-production
当我的Rails应用程序处于开发模式时,如何删除代码?例如,我想在开发过程中删除我的Google Analytics参考,但要在生产环境中进行渲染.
是否有可以在视图或控制器中实现的解决方案?我可以看到两者都需要.
<% if Rails.env == 'production' %>
...production code goes here...
<% end %>
Run Code Online (Sandbox Code Playgroud)
这适用于Rails 3.在旧版本中,用户使用环境变量RAILS_ENV.
知更鸟
| 归档时间: |
|
| 查看次数: |
725 次 |
| 最近记录: |