2013-02-10 62 views
0

我正在一個非常簡單的項目管理Web應用程序。投訴,路線不在,但它不是

我有兩個不同的頁面查看項目。

1. View all projects 
2. View only the projects where you are administrator (includes buttons for editing/deletion of the projects) 

因爲我有我展示決定創建將用戶引導到項目控制器中的自定義操作的自定義路線的項目,兩個不同的頁面。

然而,這並不能(由於某種原因)的工作,我也得到了以下錯誤消息:

No route matches {:action=>"edit", :controller=>"projects"} 

的觀點:

<%= link_to "Manage projects", users_projects_path %> 

項目負責人:

class ProjectsController < ApplicationController 
    ... 
    def users_projects 
     @users_projects = Project.where(:user_id => current_user.id) 
    end 
... 
end 

項目模型:

class Project < ActiveRecord::Base 
    has_and_belongs_to_many :users, :class_name => 'User' 

    belongs_to :user 
    has_many :tickets, :dependent => :destroy 

    //validation 

    attr_accessible :user_id, :title, :description, :start_date, :end_date 
end 

回答

4

的問題是,你是不是給人一種id參數的路線,這是必需的。

某處,您正在生成鏈接到edit_project_path。確保你正在給一個項目的URL生成器:edit_project_path(project)

+0

+1,作爲一個真棒Android人作爲我自己...哦,和答案。這也很好。 :) – Josiah 2013-02-10 21:54:39

+0

好吧,但在這種情況下,我想重定向用戶到所有項目(用戶擁有),而不是一個特定的頁面。這怎麼可能完成? – holyredbeard 2013-02-11 07:50:43

+0

當您顯示鏈接或有人點擊鏈接時是否發生錯誤消息?我的猜測是,它是在有人點擊它之後,因此它是顯示拋出錯誤的所有配置文件的頁面。如果顯示路線文件和完整的錯誤跟蹤消息,它可能會有所幫助。 – 2013-02-11 22:14:12

相關問題