ActionView::Template::Error (No route matches {:action=>"update",
:controller=>"text_posts"}):
<h1><%= text_post.blog %></h1>
<%= form_tag do %>
<%= link_to "New Text Post", controller: "text_posts", action: "new" %>
<%= link_to "Edit", controller: "text_posts", action: "update" %>
<%= link_to "Delete", controller: "text_posts", action: "destroy" %>
<% end %>
<span class='likes pull-left'>
new_image_link GET /image_links/new(.:format) image_links#new
edit_image_link GET /image_links/:id/edit(.:format) image_links#edit
image_link GET /image_links/:id(.:format) image_links#show
PATCH /image_links/:id(.:format) image_links#update
PUT /image_links/:id(.:format) image_links#update
DELETE /image_links/:id(.:format) image_links#destroy
text_posts GET /text_posts(.:format) text_posts#index
POST /text_posts(.:format) text_posts#create
new_text_post GET /text_posts/new(.:format) text_posts#new
edit_text_post GET /text_posts/:id/edit(.:format) text_posts#edit
text_post GET /text_posts/:id(.:format) text_posts#show
PATCH /text_posts/:id(.:format) text_posts#update
PUT /text_posts/:id(.:format) text_posts#update
DELETE /text_posts/:id(.:format) text_posts#destroy
答案 0 :(得分:3)
您可以这样做:
<%= link_to "Edit", edit_text_post_path(text_post) %>
答案 1 :(得分:1)
<%= link_to "Edit", edit_text_post_path(text_post) %>
<%= link_to "Delete", text_post_path(text_post), :method => :delete %>
match ':controller(/:action(/:id(.:format)))', :via => :all
即便如此,你仍然必须给它想要编辑的text_post,因为它需要在url的末尾有一个id。所以应该是这样的:
<%= link_to 'Edit', :controller => 'text_posts', :action => 'edit', :id => text_post %>
<%= link_to 'Delete', :controller => 'text_posts', :action => 'destroy', :id => text_post %>
希望它有所帮助。
答案 2 :(得分:0)
试试这个.................
<h1><%= text_post.blog %></h1>
<%= link_to "New Text Post", new_text_post_path %>
<%= link_to "Edit", edit_text_post_path(text_post) %>
<%= link_to "Delete", text_post_path(text_post), method: :delete %>
希望这对你有用。