This project is archived and is in readonly mode.

#6652 new
Jan Lelis

Cannot include ActionView::Helpers and Rails.application.routes.url_helpers at the same time

Reported by Jan Lelis | March 30th, 2011 @ 12:08 PM

When using the Rails console you cannot include Rails.application.routes.url_helpers and ActionView::Helpers (especially FormHelper/FormTagHelper/UrlHelper) at the same time: the named routes won't work anymore:

>> some_route_url
NoMethodError: undefined method `host_with_port' for nil:NilClass
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/activesupport-3.0.5/lib/active_support/whiny_nil.rb:48:in `method_missing'
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/actionpack-3.0.5/lib/action_controller/metal/url_for.rb:9:in `url_options'
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/actionpack-3.0.5/lib/action_view/helpers/url_helper.rb:32:in `url_options'
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/actionpack-3.0.5/lib/action_dispatch/routing/url_for.rb:131:in `url_for'
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/actionpack-3.0.5/lib/action_view/helpers/url_helper.rb:99:in `url_for'
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:195:in `projects_url'
    from (irb):5
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.5/lib/rails/commands/console.rb:44:in `start'
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.5/lib/rails/commands/console.rb:8:in `start'
    from /home/ben/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.5/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages