bigvideo.js在rails路由错误?

时间:2013-11-15 17:49:30

标签: javascript ruby-on-rails jquery-plugins

所以我有一个视频背景,我想要包含在我的rails应用程序中。下面是在rails之外完美运行的html,其中所需文件都位于标题为js。

的文件夹中

然而,这在Rails中不起作用。根据服务器我有以下错误:

Started GET "/js/jquery-ui-1.8.22.custom.min.js" for 127.0.0.1 at 2013-11-15 12:46:02 -0500

ActionController::RoutingError (No route matches [GET] "/js/jquery-ui-1.8.22.custom.min.js"):
  actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
  railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
  railties (4.0.0) lib/rails/engine.rb:511:in `call'
  railties (4.0.0) lib/rails/application.rb:97:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
  /Users/ericabt1/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
  /Users/ericabt1/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
  /Users/ericabt1/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

application.html.erb

<!DOCTYPE html>
<html>
<head>
  <title>VideoRail</title>
  <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
  <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
  <%= csrf_meta_tags %>
</head>
<body>
<p>bubblers!!!!!!!!!!!!!!</p>
    <!-- BigVideo Dependencies -->
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/jquery-1.7.2.min.js"><\/script>')</script>
    <script src="js/jquery-ui-1.8.22.custom.min.js"></script>
    <script src="http://vjs.zencdn.net/c/video.js"></script>

    <!-- BigVideo -->
    <script src="js/bigvideo.js"></script>

    <!-- Demo -->
    <script>
      $(function() {
            var BV = new $.BigVideo();
      BV.init();
            BV.show('blue.mov');
      });
    </script>
<%= yield %>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

该错误似乎表明它无法找到库,请尝试使用资产标记帮助程序加载您的jquery-ui-1.8.22.custom.min.js文件

<%= javascript_include_tag("jquery-ui-1.8.22.custom.min.js") %>

假设jquery-ui-1.8.22.custom.min.js库位于app / assets / javascripts或lib / assets / javascripts或vendor / assets / javascripts

有关javascript_include_tag的详细信息,请查看Asset Tag Helpers in Rails GuideAPI documentation