I’m working on a very simple project management web app.
I have two different pages where you view the projects.
1. View all projects
2. View only the projects where you are administrator (includes buttons for editing / deletion of the projects)
Because I have two different pages for showing the projects I decided to create a custom route that directs the user to a custom action in the project controller.
However, this doesn’t (by some reason) work, and I get the following error message:
No route matches {:action=>"edit", :controller=>"projects"}
the view:
<%= link_to "Manage projects", users_projects_path %>
project controller:
class ProjectsController < ApplicationController
...
def users_projects
@users_projects = Project.where(:user_id => current_user.id)
end
...
end
project model:
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
The problem is that you are not giving an
idparameter to the route, which is required.Somewhere, you are generating a link to
edit_project_path. Ensure that you are giving a project to that url generator:edit_project_path(project)