How to use link_to when inside a subdomain

I recently implemented subdomains in my app which is working well.
But is there a way to use link_to that gets you OUT of the subdomain?
For example, if a user is at http://foo.mysite.com then

link_to ‘Sign in’, signin_path

will link to http://foo.myste.com/signin but I need the link to
instead point to http://mysite.com/signin.

I tried link_to “sign in”, signin_path(:host => “mysite.com”) but no
luck. Any ideas?

This guy did it by patching UrlRewriter:
http://s2.diffuse.it/blog/show/49_Subdomain+routing+with+rails

thanks! i added this as a file in my initializers directory.

module ActionController
class UrlRewriter
def rewrite(options = {})
options[:host] = @request.domain
rewrite_url(options)
end
end
end

now signin_url gives http://myste.com/signin but signin_path still
gives http://foo.myste.com/signin

Is there a way to fix _path as well as _url?

Is there a way to fix _path as well as _url?

Sorry, I can’t really help you here - I never used the code myself, I
only remembered having read that article. From a cursory look, it seems
to me that rewrite_url is capable of both, depending on the :only_path
parameter, but I am not sure in how far it has a hand in generating the
URL helpers.

I tried delving a bit further into it, but quite frankly, I still find
Rails Routing to be somewhat scary stuff :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs