David Crockett
2008-Sep-02 21:59 UTC
Unable to set default_url_options[:host] for Action Mailer
I am attempting to provide ActionMailer with the request host needed to generate a url. Here is my code: In config/environments/development.rb config.action_mailer.default_url_options = { :host => "development_url.com" } and in config/environments/production.rb config.action_mailer.default_url_options = { :host => "production_url.com" } When I run the above code ActionMailer fails, and tells me that I never provided it with the request host. I think ActionMailer is a dirty liar. Any suggestions for a fix? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2008-Sep-03 13:57 UTC
Re: Unable to set default_url_options[:host] for Action Mailer
David Crockett wrote:> I am attempting to provide ActionMailer with the request host needed to > generate a url. > > Here is my code: > > In config/environments/development.rb > config.action_mailer.default_url_options = { :host => > "development_url.com" } > > and in config/environments/production.rb > config.action_mailer.default_url_options = { :host => > "production_url.com" } > > > When I run the above code ActionMailer fails, and tells me that I never > provided it with the request host. I think ActionMailer is a dirty > liar. > > Any suggestions for a fix?Have you restarted your development server? If so, try putting it inside your mailer class: default_url_options[:host] = RAILS_ENV != production ? "development_url.com" : "production_url.com" -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David Crockett
2008-Sep-03 22:41 UTC
Re: Unable to set default_url_options[:host] for Action Mail
Mark Reginald James wrote:> Have you restarted your development server?Nope - restarting the server solved the problem. Thanks for the help. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Christopher Small
2010-Apr-21 03:54 UTC
Re: Unable to set default_url_options[:host] for Action Mailer
> If so, try putting it inside your mailer class: > > default_url_options[:host] = RAILS_ENV != production ? > "development_url.com" : "production_url.com" >I would recommend using Ryan Bates nifty generators gem (http://github.com/ryanb/nifty-generators). This lets you generate a nifty_config file (actually by default called app_config.yml) which lets you access variables which depend on production environment by doing APP_CONFIG[:domain] or some some such madness. Definitely beats the above method if you have to use that information in more than one place (DRY). Chris -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.