2013-02-26 76 views
0

我正在開發一個本地應用程序。 我嘗試將TableTools添加到我的數據表。 TableTools按鈕很好地顯示在頁面上,但它們沒有效果,我總是有關於swfPath的路由錯誤。Rails DataTables無法設置sSwfPath

讓TableTools在本地工作的正確方法是什麼? 感謝您的幫助

的application.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) 

我嘗試不同的事情沒有結果(複製' media「目錄中,或者我的資產/後臺/ d中的swf目錄irectory等...)沒有運氣

任何幫助將不勝感激

回答

8

已解決!

好吧,問題是與Flash(像往常一樣),確實對本地進行了一些限制。所有的工作正常,如果你把你的應用程序在Web服務器上... 但在這種情況下,我只需要在我的本地PC上開發,並使用本地主機作爲Web服務器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」目錄(我的是in: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!

希望這可以幫助

乾杯

+3

謝謝,工作完美,注意,我在Linux(Ubuntu的)和第一步並不需要我。 – rmagnum2002 2013-04-21 10:57:05

+0

我可以說Windows 8.1上的第1步也是不必要的。感謝您的解決方案! – 2015-07-24 10:12:19