Forum: Ruby on Rails Strange error: undefined method `rewrite'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vlad Berditchevskiy (Guest)
on 2006-03-12 17:30
(Received via mailing list)
Hi,

when I generate a new rails project with a simple scaffolded controller,
I get a strange error message, whenever it tries to call the url_for
method, for example:

,----
| undefined method `rewrite' for #<Url:0xb7675e64>
|
| Extracted source (around line #7):
|
| 4: </p>
| 5: <% end %>
| 6:
| 7: <%= link_to 'Edit', :action => 'edit', :id => @url %> |
| 8: <%= link_to 'Back', :action => 'list' %>
`----

,----
| /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1501:in 
`method_missing'
| /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:448:in 
`url_for'
| 
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/url_helper.rb:18:in 
`url_for'
| 
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/url_helper.rb:49:in 
`link_to'
| #{RAILS_ROOT}/app/views/urls/show.rhtml:7
`----

I looked at the source and found out that the error originates from the
following code:

,----
|       def url_for(options = {}, *parameters_for_method_reference) #:doc:
|         case options
|           when String then options
|           when Symbol then send(options, *parameters_for_method_reference)
|           when Hash   then @url.rewrite(rewrite_options(options))
|         end
|       end
`----

Where is this 'rewrite' method supposed to be and why can't it be found?

--
\  /                                       removed_email_address@domain.invalid
 \/lad                                     http://www.hashbang.de
joey__ (Guest)
on 2006-03-12 18:17
Vlad Berditchevskiy wrote:
> ,----
> | undefined method `rewrite' for #<Url:0xb7675e64>
> |
> | Extracted source (around line #7):
> |
> | 4: </p>
> | 5: <% end %>
> | 6:
> | 7: <%= link_to 'Edit', :action => 'edit', :id => @url %> |
> | 8: <%= link_to 'Back', :action => 'list' %>
> `----
>
> ,----
> | /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1501:in 
`method_missing'
> | /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:448:in 
`url_for'
> | 
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/url_helper.rb:18:in 
`url_for'
> | 
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/url_helper.rb:49:in 
`link_to'
> | #{RAILS_ROOT}/app/views/urls/show.rhtml:7
> `----
>

You can't use Url as a model name.

joey__
http://www.feedreed.com
Vlad Berditchevskiy (Guest)
on 2006-03-12 19:33
(Received via mailing list)
joey__ <removed_email_address@domain.invalid> writes:

> You can't use Url as a model name.

Thank you for the explanation, this error was driving me crazy! :-)

BTW, what's wrong with the model name Url? Are there other "forbidden"
model names?


--
\  /                                       removed_email_address@domain.invalid
 \/lad                                     http://www.hashbang.de
This topic is locked and can not be replied to.