0

なぜ私が得ているのかわからない

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

私のパーシャルの1つにあるlink_toで

関連するroutes.rb

  resources :documents, only: [:create, :destroy, :edit, :update] do
    post 'sort' => 'documents#sort', on: :collection
  end

最近、編集アクションと更新アクションを追加したので、現在の問題はルートをレーキします=

  sort_documents POST   /documents/sort(.:format)      documents#sort
       documents POST   /documents(.:format)           documents#create
   edit_document GET    /documents/:id/edit(.:format)  documents#edit
        document PUT    /documents/:id(.:format)       documents#update
                 DELETE /documents/:id(.:format)       documents#destroy

問題のあるルートの部分は

 <%= document.title %>
 <%= document.position %>
 <%= link_to 'link_to_test', edit_document_path %>
 <%= link_to 'Delete', document, method: :delete, remote: true %>

私のdocuments_controller.rbには編集が定義されています

def edit
    @document = current_user.documents.find(params[:id])
end
4

1 に答える 1

1

でオブジェクトまたはそのIDを指定し忘れたため、エラーが発生しますedit_document_path。これを試して:

<%= link_to 'link_to_test', edit_document_path(document) %>
于 2012-05-31T20:16:10.473 に答える