Controller url_for modifies request object?


In my controller, I do something like this:

MyMailer.deliver_signup_notification(url_for(:subdomain =>
account.subdomain, :controller => 'hello'))

And a few lines later:

redirect_to :action => 'index'

Much to my confusion, the redirect routes me to the subdomain used in
the url_for. I've tried

redirect_to :action => 'index', :subdomain => nil

Which changed nothing. It gets really strange when I try:

redirect_to :action => 'index', :subdomain => request.subdomains.first

Only to find that request.subdomains.first now equals
account.subdomain - which is NOT the case before the
"MyMailer.deliver_signup_notification" method. So url_for changes the
request object - which I personally dislike. Is there a work around
for this?



I may be way off here, I just wrote this test:

  def test_should_generate_correct_url
    original_url = url_for(:controller => "pages")
    url_with_subdomain = url_for(:controller => "pages", :subdomain =>
    latest_url = url_for(:controller => "pages")

    assert_equal original_url, latest_url

This passes and as far as I can see url_for doesn't modify anything.
Of course it may be something to do with a plugin you have. Can you
try something similar and let us know the results? Also, it would be
good to know which version of Rails you're running.



Thanks for the pointer Steven, it was indeed a broken plugin
(url_for_domain). There's a fixed version on the Wiki:

But this has not made it to the plugin repository.