Tôi nhận được lỗi sau:ActionController :: UrlGenerationError tại Điều # chỉnh sửa
Không trận tuyến đường {: action => "hiển thị",: controller => "bài báo",: id => nil} mất tích cần thiết khóa: [: id]
Sau đây là mã hiển thị lỗi.
<%= form_for :article, url: article_path(@article), method: :patch do |f| %>
Lỗi này là gì, bất cứ khi nào tôi nhấp vào chỉnh sửa từ màn hình trước, tôi nghĩ tôi đang gửi id bài viết.
Đây là tuyến đường cào của tôi ra
Prefix Verb URI Pattern Controller#Action
welcome_index GET /welcome/index(.:format) welcome#index
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
root GET / welcome#index
Bạn có thể đăng đầu ra 'rake routes' của mình không? – Pavan
Tôi đã bao gồm đầu ra đường rake trong câu hỏi chính nó bây giờ – user3726986
Điều gì xảy ra khi bạn thay đổi dòng đó thành '<% = form_for @article, url: article_path (@article), phương thức:: patch do | f | %> '? – Pavan