Hi, Is there a simple function in Rails that will return the current host or domain? Like if I was running on http://localhost:3000, is there a function that would return "localhost"? And if I was on the live server, like http://apples.com, is there a function that would return "apples.com"? Thanks for any 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 -~----------~----~----~----~------~----~------~--~---
Sorry to double post, but to clarify, I''m looking for a Ruby function that will do the same as Request.Url.Host -- 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 -~----------~----~----~----~------~----~------~--~---
Triple post time. Many apologies to all offended parties. In controllers and views, request.domain(2) will return the current host. Unfortunately for me, request.domain does not work in rake tasks, so I am up the creek without a paddle. -- 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 -~----------~----~----~----~------~----~------~--~---
On 8 Sep 2008, at 15:51, Joe Peck wrote:> > Triple post time. Many apologies to all offended parties. > > In controllers and views, request.domain(2) will return the current > host. > > > Unfortunately for me, request.domain does not work in rake tasks, so I > am up the creek without a paddle.That''s normal: rake tasks are outside the request cycle, so they''ve no way of knowing how people access the site (ie localhost, a dotted ip address, one of the many domain names pointing at the server). Maybe you could explain what it is you are trying to do? Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > That''s normal: rake tasks are outside the request cycle, so they''ve no > way of knowing how people access the site (ie localhost, a dotted ip > address, one of the many domain names pointing at the server). > Maybe you could explain what it is you are trying to do? > > FredI''m trying to send out an email from within the rake task, and I need to include a link in the email to a certain page on my site. In development, I''d want the page to be "http://localhost:3000/fruits/my_fruit", but in production, I''d want it to be "http://apples.com/fruits/my_fruit" I''d rather not hard-code in the domain names, I''d like some way to just grab what domain I''m on and use that. -- 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 -~----------~----~----~----~------~----~------~--~---
On 8 Sep 2008, at 16:25, Joe Peck wrote:> >> >> That''s normal: rake tasks are outside the request cycle, so they''ve >> no >> way of knowing how people access the site (ie localhost, a dotted ip >> address, one of the many domain names pointing at the server). >> Maybe you could explain what it is you are trying to do? >> >> Fred > I''m trying to send out an email from within the rake task, and I > need to > include a link in the email to a certain page on my site. > > In development, I''d want the page to be > "http://localhost:3000/fruits/my_fruit", > > but in production, I''d want it to be "http://apples.com/fruits/my_fruit > " > > I''d rather not hard-code in the domain names, I''d like some way to > just > grab what domain I''m on and use that.I think you''re going to have to have some config file or whatnot. Just looking at my server it hosts half a dozen domains - there''s no way it can guess which is the one you''re interested in this time. Fred --~--~---------~--~----~------------~-------~--~----~ 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 think you''re going to have to have some config file or whatnot. Just > looking at my server it hosts half a dozen domains - there''s no way it > can guess which is the one > you''re interested in this time. > > FredYeah, I ended up putting the info in config files. Ah well, thanks for all the advice. -- 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 -~----------~----~----~----~------~----~------~--~---