【问题标题】:Rails 3: scaffold destroy action redirect to show actionRails 3:脚手架销毁动作重定向以显示动作
【发布时间】:2011-08-24 00:25:57
【问题描述】:

我创建了一个简单的脚手架,问题是当我尝试删除记录时单击销毁导轨重定向到显示操作,这是我生成脚手架时自动生成的链接的代码:

<%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %> 

怎么了?

【问题讨论】:

    标签: ruby-on-rails-3 action scaffold


    【解决方案1】:

    您需要在应用程序布局中包含rails.js,因为此链接要求 JS 使用正确的 HTTP 方法。还要确保你的布局中有csrf_meta_tag

    【讨论】:

    • 好的,感谢 jquery 库和其他 js 文件已被注释,并且 破坏操作有效,但我怎样才能将 jquery 和原型一起包含而没有冲突?
    【解决方案2】:

    检查您的application.js 是否有//= require jquery_ujs

    【讨论】:

      【解决方案3】:

      添加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 .
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-17
        • 2015-07-18
        • 2018-09-25
        • 1970-01-01
        • 1970-01-01
        • 2013-08-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多