Ruby on rails 删除帖子重定向到帖子

Ruby on rails 删除帖子重定向到帖子,ruby-on-rails,ruby,link-to,posts,Ruby On Rails,Ruby,Link To,Posts,我目前正试图通过链接删除一篇文章 <%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } 确保/=require jquery和/=require jquery\u ujs包含在应用程序.js中,并将应用程序.js包含在视图/布局/应用程序.html.erb中,确保/=require jquery和/=require jquery\u ujs包含在您的application.js

我目前正试图通过链接删除一篇文章

<%= link_to 'Destroy',  post,  method: :delete, data: { confirm: 'Are you sure?' }

确保
/=require jquery
/=require jquery\u ujs
包含在
应用程序.js中,并将
应用程序.js
包含在
视图/布局/应用程序.html.erb
中,确保
/=require jquery
/=require jquery\u ujs
包含在您的
application.js中
和包含在
view/layout/application.html.erb中的include
application.js

您的
application.js中是否包含
/=require jquery
/=require jquery\u ujs
?并且
application.js
是否包含在
view/layout/application.html.erb
中?我只是添加了//=require jquery\u ujs。很好,谢谢你,伙计!我添加了解决方案作为答案。您的
应用程序.js中是否包含
/=require jquery
/=require jquery\u ujs
?并且
application.js
是否包含在
view/layout/application.html.erb
中?我只是添加了//=require jquery\u ujs。很好,谢谢你,伙计!我已经添加了解决方案作为答案。
  <table>
<tr>
  <th>titre</th>
  <th>description</th>
</tr>
<% @posts.each do |post| %>
<tr>
  <td><%= post.title %></td>
  <td><%= post.description %></td>
  <td><%= link_to 'Show', post_path(post)%> </td>
  <td><%= link_to 'Edit', edit_post_path(post) %></td>
  <td><%= link_to 'Destroy',  post,  method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<br>
class PostsController < ApplicationController

  before_action :set_post, except: [:create, :index, :new]
  def index
   @posts =  Post.all
  end

  def show
  end

  def new
   @post = Post.new
  end

  def edit
  end

  def create
    @post = Post.new(post_params)
    @post.save
     redirect_to :action => "index"
  end

  def update
     respond_to do |format|
      if @post.update(post_params)
        format.html { redirect_to @post, notice: 'Lime was successfully updated.' }
      else
    format.html { render :edit }
      end
    end
  end

  def destroy
    @post.destroy
    redirect_to root_path, :notice => "Vous n'êtes plus un batard"
  end

  private #private has nos end

    #Must be set to update later
    def set_post
      @post = Post.find(params[:id])
    end

    def post_params
      params.require(:post).permit(:title, :description)
    end
end