0

我正在本地开发一个应用程序。我尝试将 TableTools 添加到我的数据表中。TableTools 按钮在页面上显示很好,但是没有效果,我总是遇到关于 swfPath 的路由错误。

让 TableTools 在本地工作的正确方法是什么?感谢帮助

应用程序.js

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap
//= require dataTables/extras/TableTools
//= require dataTables/extras/ZeroClipboard
//= require_tree .

users.js.coffee

jQuery ->

  #  Init the table
  $('#users-grid').dataTable
    bjQueryUI: true
    sDom: 'T<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>'
    oTableTools:
      sSwfPath: "swf/copy_csv_xls_pdf.swf"
    sPaginationType: "bootstrap"
    bProcessing: true
    bServerSide: true
    sAjaxSource: $('#users-grid').data('source')

服务器日志

Started GET "/backstage/swf/copy_csv_xls_pdf.swf" for 127.0.0.1 at 2013-02-26 11:48:11 +0100

ActionController::RoutingError (No route matches [GET]   "/backstage/swf/copy_csv_xls_pdf.swf"):
  actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
  quiet_assets (1.0.1) lib/quiet_assets.rb:20:in `call_with_quiet_assets'
  actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
 activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
 rack (1.4.5) lib/rack/lock.rb:15:in `call'
 actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'
 railties (3.2.1) lib/rails/engine.rb:479:in `call'
 railties (3.2.1) lib/rails/application.rb:220:in `call'
 rack (1.4.5) lib/rack/content_length.rb:14:in `call'
 railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
 rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
 C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
 C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
 C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

  Rendered C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)

我尝试了不同的事情但没有结果(复制我的 app/assets 目录中的“media”目录,或者我的 assets/backstage/' 目录中的 swf 目录等......)没有运气

任何帮助将不胜感激

4

1 回答 1

8

解决了 !

好的,问题出在Flash(像往常一样)上,它确实对本地设置了一些限制。如果您将您的应用程序放在网络服务器上,一切正常......但在这种情况下,我只需要在我的本地 PC 上开发并使用 localhost 作为网络服务器,Flash 会发出嘘声。在谷歌搜索并尝试了很多之后,我找到了一个可行的解决方案,我把它放在她身上,以防它对其他人有帮助:

我在 Windows8 上使用 Rails 3.2.11 和 Ruby 1.9.3(通过 RailsInstaller 安装)

1-为了避免本地的 Flash 限制(Flash 不授权加载本地文件)去http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html#119065和“始终授权”

2 - 从 DataTable 中找到“swf”目录(我的位于:C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\jquery-datatables-rails-1.11.2\vendor\assets\ media\dataTables\extras\swf) 将其复制/粘贴到您的应用程序/公共/...

3 将 sSwfPath 设置为

sSwfPath: "http://localhost:3000/swf/copy_csv_xls_pdf.swf"

完成了,一切都应该正常了。在生产时不要忘记更改 sSwfPath !

希望这会有所帮助

干杯

于 2013-02-27T10:07:46.407 回答