Hi, how can I call the url in an actionMailer definition - so that it automatically detects what the rails application server is and puts it in the url that is mailed to the client? (I don''t want to have to change it every time the hostname is changed - I''d like the application to auto detect what the host is - whether it''s localhost:3000 or my own website... example: class UserNotifier < ActionMailer::Base def signup_notification(user) setup_email(user) @subject += ''Please activate your new account'' @body[:url] "http://localhost:3000/account/activate/#{user.activation_code}" end I think this has been answered on the forum already, but from the answers I could find, I still can''t figure it out... I hope my question is clear... Thanks! Dustin -- 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 -~----------~----~----~----~------~----~------~--~---
I''m thinking the solution to my dilemma is to use the url_for function from the UrlWriter module... I haven''t figured it out yet - wondering if this is the right way to go... isn''t there just an easy way to figure out what the domain is that you''re in and pass it back to the application? -- 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 -~----------~----~----~----~------~----~------~--~---
request.host much? :) On 2/16/07, Dustin Anderson <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I''m thinking the solution to my dilemma is to use the url_for function > from the UrlWriter module... > > I haven''t figured it out yet - wondering if this is the right way to > go... isn''t there just an easy way to figure out what the domain is that > you''re in and pass it back to the application? > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Russell Norris wrote:> request.host much? :)Thanks - that''s definitely what I want to do, but I can''t figure out how to call it/where to call it... it doesn''t seem to work from the model. we are sending a user activation confirmation e-mail from ActionMailer We are trying to build a URL in the user_notifier.rb model based on the hostname... how can I access the server''s hostname from a model? 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-/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 -~----------~----~----~----~------~----~------~--~---
Dustin Anderson wrote:> Hi, > > how can I call the url in an actionMailer definition - so that it > automatically detects what the rails application server is and puts it > in the url that is mailed to the client?As far as I know, you have to pass it in as a parameter, since it''s only the controller that can accurately determine the url. For example, UserNotifier.deliver_signup_notification( @user, url_for(:controller => :account, :action => :activate, :code => activation_code(@user) ) Then in your mailer method, you have something like: def signup_notification(user, activation_url) [...] @body[''url''] = activation_url [...] end --Al Evans -- 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 -~----------~----~----~----~------~----~------~--~---