Strange error: undefined method `rewrite'


#1

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:inurl_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:inlink_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


#2

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:inurl_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:inlink_to’
| #{RAILS_ROOT}/app/views/urls/show.rhtml:7
`----

You can’t use Url as a model name.

joey__
http://www.feedreed.com


#3

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! :slight_smile:

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