What''s the "right" way to DRY up this statement in my app? if ::Rails.env == ''staging'' domain = ''.staging-domain.com'' else domain = ''.production-domain.com'' end I am using it in a mailer, as well as, the session_store.rb initializer. Not sure how I should make this "domain" variable available across my entire app the "Rails" way. Thanks! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Jul 26, 2012, at 3:30 PM, John Doe wrote:> What''s the "right" way to DRY up this statement in my app? > > if ::Rails.env == ''staging'' > domain = ''.staging-domain.com'' > else > domain = ''.production-domain.com'' > end > > I am using it in a mailer, as well as, the session_store.rb initializer. > > Not sure how I should make this "domain" variable available across my > entire app the "Rails" way.I would put it in your config/environments/[environment].rb files, one per environment, or put the local (test/development) one in your environment.rb file, and the deployment version in the production.rb file. Walter> > Thanks! > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Domain = (::Rails.env == "staging" ? Staging-domain : other-domain) Handy posted... Am 26.07.2012 21:30 schrieb "John Doe" <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> What''s the "right" way to DRY up this statement in my app? > > if ::Rails.env == ''staging'' > domain = ''.staging-domain.com'' > else > domain = ''.production-domain.com'' > end > > I am using it in a mailer, as well as, the session_store.rb initializer. > > Not sure how I should make this "domain" variable available across my > entire app the "Rails" way. > > Thanks! > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Thursday, 26 July 2012 15:30:42 UTC-4, Ruby-Forum.com User wrote:> > What''s the "right" way to DRY up this statement in my app? > > if ::Rails.env == ''staging'' > domain = ''.staging-domain.com'' > else > domain = ''.production-domain.com'' > end > > I am using it in a mailer, as well as, the session_store.rb initializer. > > Not sure how I should make this "domain" variable available across my > entire app the "Rails" way. > >Probably the best would be to set it as the default host: config.routes.default_url_options[:host] = ''something.com'' in each environment. This has the added bonus of ensuring that full URLs always get generated with the right host. You *may* need to also set config.action_mailer.default_url_options[:host] to get the same information to your mailers. --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/eFU5yzgZ7F8J. For more options, visit https://groups.google.com/groups/opt_out.