Hi, I have a cron job running at pre-determined time. This cron job is a small Ruby script that loads the whole Rails environment and does some jobs. One of the job is to send a link to users. The link needs to be full qualified. Meaning, it should be something like http://ww.myapp.com/user/activate/asdfe234sv. The domain part in the URL is variable. The cron job could be running from dev or staging or production servers. How can I generate these URLs? Named routes aren''t allowed in this Ruby script. To get to routes I have to do something like: ::ActionController::Routing::Routes But even with that I am not able to generate the link. I tried url_for(:controller => ''user'', :action => ''activate) and that doesn''t work either. Any ideas how I can do this? At the moment I have hard-coded the domain part in the script file. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2008-Apr-10 10:09 UTC
Re: Generating fully qualified URL based on the server
where do you get the fully hostname from? if you open the rails environment in a simple ruby script, you wont'' have a hostname, you''ll have to specify it yourself. the url_for() method ought to give you the relative path on the hostname that you need to get the rest of the URL. Does this help? Julian. Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) VIDEO #3 out NOW! http://sensei.zenunit.com/ On 10/04/2008, at 7:46 PM, Subbu wrote:> > Hi, > > I have a cron job running at pre-determined time. This cron job is a > small Ruby script that loads the whole Rails environment and does some > jobs. One of the job is to send a link to users. The link needs to be > full qualified. Meaning, it should be something like > http://ww.myapp.com/user/activate/asdfe234sv. The domain part in the > URL is variable. The cron job could be running from dev or staging or > production servers. How can I generate these URLs? > > Named routes aren''t allowed in this Ruby script. To get to routes I > have to do something like: > ::ActionController::Routing::Routes > > But even with that I am not able to generate the link. I tried > url_for(:controller => ''user'', :action => ''activate) and that doesn''t > work either. Any ideas how I can do this? > > At the moment I have hard-coded the domain part in the script file. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---