crumble
crumble copied to clipboard
Routing troubles
Some routes are causing problems for me, specifically these: http://localhost:3000/projects/2/releases/1/sprints/new http://localhost:3000/projects/2/releases/1/teams/new
The error I get says: project_url failed to generate from {:action=>"show", :controller=>"projects"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["projects", :id] - are they all satisfied?
Here's my breadcrumbs.rb configuration file:
Breadcrumb.configure do
# Specify name, link title and the URL to link to
crumb :root, "Dashboard", :root_url
crumb :project, "Project", :project_url
crumb :story, "Story", :project_story_url
crumb :task, "Task", :project_task_url
crumb :release, "Release", :project_release_url
crumb :sprint, "Sprint", :project_release_sprint_url
crumb :team, "Team", :project_release_team_url
# Specify controller, action, and an array of the crumbs you specified above
trail :projects, :dashboard, [:root]
trail :projects, [:show, :new, :edit], [:root, :project]
trail :stories, [:new, :show, :edit], [:root, :project, :story]
trail :tasks, [:new, :show, :edit], [:root, :project, :task]
trail :releases, [:new, :show, :edit], [:root, :project, :release]
trail :sprints, [:new, :show, :edit], [:root, :project, :release, :sprint]
trail :teams, [:new, :show, :edit], [:root, :project, :release, :team]
# Specify the delimiter for the crumbs
delimit_with " / "
dont_link_last_crumb
end
Here's my routes.rb file:
ActionController::Routing::Routes.draw do |map|
map.root :controller => 'projects', :action => 'index'
map.dashboard "dashboard", :controller => 'projects', :action => 'dashboard'
map.project_settings "projects/:id/settings", :action => 'settings', :controller => 'projects'
map.project_unassigned_stories "projects/:project_id/stories/unassigned", :action => 'unassigned', :controller => 'stories'
map.resources :projects do |projects|
projects.resources :stories do |stories|
stories.resources :comments
stories.resources :watches
stories.resources :votes
stories.resources :tags
stories.resources :tasks
stories.resources :defects
stories.resources :attachments
stories.resources :timers, :collection => { :stop => :post, :elapsed => :get }
end
projects.resources :releases do |releases|
releases.resources :teams
releases.resources :sprints
end
projects.resources :pages
end
map.connect ':controller/:id/:action'
map.connect ':controller/:id/:action.:format'
end
Using the _url methods won't automatically insert the objects for you. Given the convention of resources it probably could, but instead of using the symbol syntax for the URL generation, you could use 'project_url(@project)' as string instead of just :project_url.