controller variables named @url – don’t do it!

Posted by chad on November 07, 2007

Don’t name your variable @url, then use any of the url helpers such as url_for, link_to_remote, etc. If you do, you’ll get this error:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.rewrite
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:522:in `url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/url_helper.rb:27:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/url_helper.rb:27:in `url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/prototype_helper.rb:242:in `remote_function'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/prototype_helper.rb:133:in `link_to_remote'
#{RAILS_ROOT}/app/views/seo/_listtable.rhtml:103:in `_run_rhtml_47app47views47seo47_listtable46rhtml'
#{RAILS_ROOT}/app/views/seo/list.rhtml:3:in `_run_rhtml_47app47views47seo47list46rhtml'
/usr/bin/rdebug-ide:16:in `load'
/usr/bin/rdebug-ide:16
-e:4:in `load'
-e:4
Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

Comments