У меня есть этот код:
<table>
<% @posts.each do |post| %>
<tr>
<td><%= post.created_at.utc.strftime("%d.%m.%Y") %></td>
<td><%= link_to(post.title, {:controller=>:blog,:action=>:show, :id=>post}) %></td>
<td><%= link_to 'Edit', edit_post_path(post) %></td>
<td><%= link_to 'Destroy', {:controller=>:posts,:action=>:destroy, :id=>post}, :method=>:delete %></td>
</tr>
<% end %>
Проблема в том, что link_to 'Destroy' не удаляет сообщения, а просто открывает их. Любые предложения, чтобы решить эту проблему?
Файл
rout.rb:
LivuPamatskola::Application.routes.draw do
resources :posts
get "admin/rakstu_red"
get "home/par_skolu"
get "home/personals"
get "home/kontakti"
get "home/pers_pieeja"
get "home/galerijas"
get "home/index"
root :to => 'home#index'
posts.controller.rb уничтожить раздел:
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to posts_url }
format.json { head :no_content }
end
end
application.js:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
макет головы:
<head>
<title>Līvu pamatskola</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<%= stylesheet_link_tag 'style' %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
РЕШИТЬ:
Наше сообщение найдено: Rails 3.1 link_to не показывает подтверждение или уничтожает должным образом
В любом случае, спасибо, ребята, за помощь!