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

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3337 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.