Vlad Berditchevskiy
2006-Mar-12 15:30 UTC
[Rails] Strange error: undefined method `rewrite''
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? -- \ / vlad@hashbang.de \/lad http://www.hashbang.de
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 -- Posted via http://www.ruby-forum.com/.
Vlad Berditchevskiy
2006-Mar-12 17:30 UTC
[Rails] Re: Strange error: undefined method `rewrite''
joey__ <cardologist@gmail.com> 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? -- \ / vlad@hashbang.de \/lad http://www.hashbang.de