I keep getting these errors for no route matches for actions ‘edit’
controller:
def remove_artifact_from_collection
... do my stuff ..
render(:action=>:show)
end
view: the line on which it errors
<p><%= link_to 'Edit Evidence Item', edit_artifact_path, :class => 'edit_button' %></p>
routes:
resources :artifacts do
collection do
get 'remove_artifact_from_collection'
end
end
bundle exec rake routes
remove_artifact_from_collection_artifacts GET /artifacts/remove_artifact_from_collection(.:format) {:controller=>"artifacts", :action=>"remove_artifact_from_collection"}
artifacts GET /artifacts(.:format) {:controller=>"artifacts", :action=>"index"}
POST /artifacts(.:format) {:controller=>"artifacts", :action=>"create"}
new_artifact GET /artifacts/new(.:format) {:controller=>"artifacts", :action=>"new"}
edit_artifact GET /artifacts/:id/edit(.:format) {:controller=>"artifacts", :action=>"edit"}
artifact GET /artifacts/:id(.:format) {:controller=>"artifacts", :action=>"show"}
PUT /artifacts/:id(.:format) {:controller=>"artifacts", :action=>"update"}
DELETE /artifacts/:id(.:format) {:controller=>"artifacts", :action=>"destroy"}
That’s because you’re not supplying an artifact/id to
edit_artifact_path. Assuming your artifact is in the@artifactinstance variable, you should use:link_to 'Edit Evidence Item', edit_artifact_path(@artifact), ...You could also use:
link_to 'Edit Evidence Item', [:edit, @artifact], ...