0

我正在开发一个非常简单的项目管理网络应用程序。

我有两个不同的页面,您可以在其中查看项目。

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

1 回答 1

4

问题是您没有为id路由提供参数,这是必需的。

在某处,您正在生成指向edit_project_path. 确保您为该 url 生成器提供了一个项目:edit_project_path(project)

于 2013-02-10T21:52:24.483 回答