Ruby-on-rails – How do I prohibit running code in the development environment on Rails?

How do I delete code when my Rails application is in development mode? For example, I want to delete my Google Analytics reference during development, but render it in a production environment.

Is there a solution that can be implemented in a view or controller? I can see that both are needed.

<% if Rails.env == 'production' %>
...production code goes here...
<% end %>

This is for Rails 3. In older versions, users use environment variables RAILS_ENV.

Robin

How do I delete code when my Rails application is in development mode? For example, I want to delete my Google Analytics reference during development, but render it in a production environment.

Is there a solution that can be implemented in a view or controller? I can see that both are needed.

<% if Rails.env =='production' %>
... production code goes here...
<% end %>

This applies to Rails 3. In older versions, users use the environment variable RAILS_ENV.

Robin

Leave a Comment

Your email address will not be published.