I would like my Rails app to supply a callback url to another app. I currently have a yaml file in the config folder in which I put the host name, but I would like to be able to query that dynamically and do away with the yaml file. Is there a method call that returns the current host? -- 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=.
On Nov 19, 7:55 pm, explainer <keburg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would like my Rails app to supply a callback url to another app. I > currently have a yaml file in the config folder in which I put the > host name, but I would like to be able to query that dynamically and > do away with the yaml file. Is there a method call that returns the > current host?Sort of - a given request has a host name (look at the methods on ActionController::Request), obviously you can only get at that inside a controller action. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
request.host -- 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=.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> explainer wrote: <blockquote cite="mid:063fc619-f274-4651-beae-98222032e1fb-Vbm8eOPh33J67GOBE4rzimB/v6IoIuQBVpNB7YpNyf8@public.gmane.org" type="cite"> <pre wrap="">I would like my Rails app to supply a callback url to another app. I currently have a yaml file in the config folder in which I put the host name, but I would like to be able to query that dynamically and do away with the yaml file. Is there a method call that returns the current host? -- </pre> </blockquote> <br> You should be able to do "name = system ''hostname'' " if you are on a linux host. This will not give the name used by a virtual host though.<br> </body> </html> <p></p> <p>--</p> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.<br /> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org<br /> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org<br /> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.<br />
Try request.env[''HTTP_HOST''] in the controller. -- 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=.
That assumes you are on the default port (80). On Nov 19, 3:47 pm, Norm Scherer <normsche...-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote:> explainer wrote:I would like my Rails app to supply a callback url to another app. I currently have a yaml file in the config folder in which I put the host name, but I would like to be able to query that dynamically and do away with the yaml file. Is there a method call that returns the current host? -- > You should be able to do "name = system ''hostname'' " if you are on a linux host. This will not give the name used by a virtual host though.-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
To find what the machine thinks its own name is (which may or may not be related to the hostname you want in a callback url), try: Socket.gethostname As has been pointed out, the callback url also needs things like the port. If you are generating this within a controller action, you could of course just use the url_for() helper to generate the callback url. -- 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=.
request.env["SERVER_ADDR"] // this will return you server ip address request.server_name or request.host // this will return host name On Nov 20, 1:55 am, explainer <keburg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would like my Rails app to supply a callback url to another app. I > currently have a yaml file in the config folder in which I put the > host name, but I would like to be able to query that dynamically and > do away with the yaml file. Is there a method call that returns the > current host?Syed Samiuzzaman software Engineer Code71 Inc (www.code71.com) product: www.scrumpad.com blog: samiuzzaman.blogspot.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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
An example that has caused me to have to use a config.yml, ActionMailer will not have request.* available. System calls would not work in this case either, since they would return a bad value on vhosts or in cases where the hostname is different than request.host. -eric On Nov 19, 11:57 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 19, 7:55 pm, explainer <keburg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I would like my Rails app to supply a callback url to another app. I > > currently have a yaml file in the config folder in which I put the > > host name, but I would like to be able to query that dynamically and > > do away with the yaml file. Is there a method call that returns the > > current host? > > Sort of - a given request has a host name (look at the methods on > ActionController::Request), obviously you can only get at that inside > a controller action. > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
request.host_with_port() in rails 2.3.4 api 2009/11/20 shweta <shweta.helwade-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Try request.env[''HTTP_HOST''] in the controller. > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=. > > >-- tommy xiao E-mail: xiaods(AT)gmail.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.
On Thu, 2009-11-19 at 11:55 -0800, explainer wrote:> I would like my Rails app to supply a callback url to another app. I > currently have a yaml file in the config folder in which I put the > host name, but I would like to be able to query that dynamically and > do away with the yaml file. Is there a method call that returns the > current host? >probably you want to write a little rack middleware app here, check this link and the comments with code underneath, http://coderack.org/users/laktek/entries/11-server-proxy> -- > > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=. > >
check database.yml file in config directory On Nov 20, 12:55 am, explainer <keburg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would like my Rails app to supply a callback url to another app. I > currently have a yaml file in the config folder in which I put the > host name, but I would like to be able to query that dynamically and > do away with the yaml file. Is there a method call that returns the > current host?-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.