What would be the most simple way to configure different variables(for ex. i have variable in tag link_to, which changing, depending on current Rails.env) ?
<%
if Rails.env == 'development'
domain = 'somedomain.me'
elsif Rails.env == 'staging'
domain = 'example.com'
end
%>
<%= link_to 'Back', root_url(:subdomain => 'www', :domain => domain), :class=>"btn btn-primary"%>
I want to move this if – elsif statement to somewhere else, or even drop it for some kind of ‘configuration files’ if any exists
There’s an awesome gem for just this, called
rails_config: github repoBut if you just want to configure this and only this variable, you could create a constant at the environment configuration files that rails already has.
Something like:
In your config/environments/production.rb
In your config/environments/development.rb
In your config/environments/staging.rb
Other methods to do that are discussed in another answers, at this thread:
https://stackoverflow.com/a/5053882
Best regards