# Undefined Method 'rewrite' when calling link\_to

**URL:** <https://www.ruby-forum.com/t/undefined-method-rewrite-when-calling-link-to/91352>\
**Category:** Rails\
**Created:** [April 7, 2007, 8:06am UTC](https://www.ruby-forum.com/t/undefined-method-rewrite-when-calling-link-to/91352 "2007-04-07T08:06:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zakifataya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/c89c15/32.png) [@zakifataya](https://www.ruby-forum.com/u/zakifataya)\
**Post date:** [April 7, 2007, 8:06am UTC](https://www.ruby-forum.com/t/undefined-method-rewrite-when-calling-link-to/91352/1 "2007-04-07T08:06:19Z")

</div>

Whenever I try to pass an options hash to the link\_to method (or  
url\_for, or button\_to) I get this error:

undefined method `rewrite’ for  
[]:ActionController::Routing::PathSegment::Result

The trace ends with

/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action\_controller/base.rb:522:in  
`url_for' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_view/helpers/url_helper.rb:27:in`send’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action\_view/helpers/url\_helper.rb:27:in  
`url_for' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_view/helpers/url_helper.rb:75:in`link\_to’

url.rewrite is defined in a module named “url\_rewriter.rb”, so I know  
it;s there.

Why is this happening?

---

<div class="post-metadata">

**Author:** ![zakifataya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/c89c15/32.png) [@zakifataya](https://www.ruby-forum.com/u/zakifataya)\
**Post date:** [April 7, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/undefined-method-rewrite-when-calling-link-to/91352/2 "2007-04-07T19:24:34Z")

</div>

Figured it out. I had a route with a parameter named ‘url’. Apparently,  
that was confusing Rails; I assume ‘url’ is reserved (or at least  
reserved from a practical point of view).

Funny, but testing in console worked fine. This seems like a problem -  
if it fails in the real world, it should fail in console (else what’s  
the point of checking your routing in console?).

Something similar happened once when I named a model “file”.
