This project is archived and is in readonly mode.

#807 ✓wontfix
ElectroNick

exception when trying to get resource url

Reported by ElectroNick | August 12th, 2008 @ 07:07 PM | in 2.x

I have the following routes (simplified version):

ActionController::Routing::Routes.draw do |map|

map.resources :projects do |project|

project.resources :calendar_events, :path_prefix => '/calendar', :as => 'events'
project.resources :calendar_exceptions, :path_prefix => '/calendar', :as => 'exceptions'

project.calendar '/calendar/:action', :controller => 'Calendar'

end

map.resources :calendar_events, :path_prefix => '/calendar', :as => 'events' map.resources :calendar_exceptions, :path_prefix => '/calendar', :as => 'exceptions' map.calendar '/calendar/:action', :controller => 'Calendar'

# Install the default route as the lowest priority. map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id' end

when I'm trying to get url using new_calendar_event_url() everything work fine, but when I try to get it using new_project_calendar_event(@project) I get the following exception: You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_sym

Stack trace: vendor/rails/actionpack/lib/action_controller/routing/route.rb:145:in extra_keys' vendor/rails/actionpack/lib/action_controller/routing/route.rb:145:inmap' vendor/rails/actionpack/lib/action_controller/routing/route.rb:145:in extra_keys' generated code (D:/projects/wt/trunk/vendor/rails/actionpack/lib/action_controller/routing/route.rb:45):3:ingenerate' vendor/rails/actionpack/lib/action_controller/routing/route.rb:122:in generate' vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:337:ingenerate' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:131:in rewrite_path' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:110:inrewrite_url' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:88:in rewrite' vendor/rails/actionpack/lib/action_controller/base.rb:621:inurl_for' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:71:in send' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:71:inurl_for' (eval):17:in new_project_calendar_exception_url' app/views/calendar/_legend.html.erb:50:in_run_erb_47app47views47calendar47_legend46html46erb' app/views/calendar/index.html.erb:18:in _run_erb_47app47views47calendar47index46html46erb' script\server:3

Btw, it works fine after removing :path_prefix => '/calendar' from line

project.resources :calendar_events, :path_prefix => '/calendar', :as => 'events'

but unfortunately this is not url I need.

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

Tags

Pages