Url_for problems

This is in the production version, 1.16, NOT in the 1.2RC.

I’m having severe problems generating more than one URL per request. For
example,

@url = url_for(‘action’ => ‘accept_invitation’, ‘conf’ => conf)
@block_url = url_for(‘action’ => ‘block_email’, ‘conf’ => em)

(where “conf” is a Base64-encoded string)

If I call the first one first, the second one throws an exception of the
general form:

Exception: undefined method rewrite' for "http://localhost:3000/accept_invite/bW9hdEBmbG9hdC5jb20%3D":String /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:488:inurl_for’
/Users/al/Development/RyanKoonce/WheresYourDollar/public/…/config/…/app/controllers/members_controller.rb:354:in
`block_email_url’

Yes, the string which has the “undefined method ‘rewrite’” is the first
URL I generated.

If I switch the order and call the second one first, both work. Once.

But if I’m generating a number of URLs, the next call to either one
throws the same exception.

The only workaround I’ve found is using something like…

@url = “http://” + request.host_with_port + “/accept_invite/” + conf

…which sucks:-)

Is there some kind of magic incantation I’m missing to “reset” url_for?

–Al Evans

Al Evans wrote:

@url = url_for(‘action’ => ‘accept_invitation’, ‘conf’ => conf)
^^^^

As it turns out, the name @url is used in ActionController::Base.

After I overwrote it with a string, it didn’t work any more:-)

I plan to remember this next time I’m writing code that will be used,
subclassed, included, or otherwise accessed by other people. Sort of
like the days of writing C libraries: DON’T use common names for
accessible variables in library code.

@action_controller_url might have been a better choice.

–Al Evans