我理解路线的概念,但有时它们不能正常工作。在这种特定情况下,我试图让编辑项目的路线工作,但我收到以下错误消息:
No route matches [POST] "/projects/8/edit"
路线.rb:
Ampta::Application.routes.draw do
get "home/index"
resources :sessions, only: [:new, :create, :destroy]
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
resources :projects do
collection do
get "manage"
end
end
resources :projects
resources :tickets
resources :projects_users
resources :users
root :to => 'home#index'
end
控制器:
class ProjectsController < ApplicationController
def edit
// no code yet
end
end
看法:
<% @users_projects.each do |project| %>
<%= link_to project.title, project_path(project), :class => "manage_project_link" %>
<%= button_to "Edit", edit_project_path(project), :class => "btn edit_button" %>
<% end %>
怎么了?运行rake 路由时要找到该路由
edit_project GET /projects/:id/edit(.:format) projects#edit