Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 主干应用程序未在生产中初始化_Ruby On Rails_Backbone.js_Heroku_Requirejs - Fatal编程技术网

Ruby on rails 主干应用程序未在生产中初始化

Ruby on rails 主干应用程序未在生产中初始化,ruby-on-rails,backbone.js,heroku,requirejs,Ruby On Rails,Backbone.js,Heroku,Requirejs,我有一个主干(1.1.0)Rails(4.1.0)应用程序,使用RequireJS(gem),在我的本地机器上运行良好。但是,当我预编译资产并启动服务器时,由r.js编译/压缩的主干应用程序不会启动。任何地方都不会抛出错误。以下是一些片段: requirejs.yml paths: jquery: "jquery/jquery" underscore: "underscore/underscore" backbone: "backbone/backbone" "j

我有一个主干(1.1.0)Rails(4.1.0)应用程序,使用RequireJS(gem),在我的本地机器上运行良好。但是,当我预编译资产并启动服务器时,由r.js编译/压缩的主干应用程序不会启动。任何地方都不会抛出错误。以下是一些片段:

requirejs.yml

paths:
    jquery: "jquery/jquery"
    underscore: "underscore/underscore"
    backbone: "backbone/backbone"
    "jquery-mobile": "jquery-mobile-bower/js/jquery.mobile-1.4.2.min"
    tpl: "requirejs-tpl/tpl"
    "backbone-query-parameters": "backbone-query-parameters/backbone.queryparams"
    serializeJSON: "jquery.serializeJSON/jquery.serializejson"
    "jqm-config": "jqm-config"
    fastclick: "fastclick/lib/fastclick"

shim:
    "backbone-query-parameters":
        deps: ['backbone']
    'jqm-config':
        deps: ["jquery-mobile"]
    'jquery-mobile':
        deps: ["jquery"]

modules:
  - name: 'application' # default

tpl:
    extension: '.html' # default
application.js

define(["backbone", "./router", "jquery-mobile", "jqm-config", "fastclick"],
function(Backbone, Router) {

var BackboneApp = {

    start: function() {
        this.router = new Router();
        Backbone.history.start();
    }
};

return BackboneApp.start();
})
application.html.erb

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <%= stylesheet_link_tag "application", :media => "all" %>
  <%= csrf_meta_tags %>
</head>
<body>
    hello
    <%= yield %>
<%= requirejs_include_tag "application" %>
</body>
</html>
为了澄清任何困惑,下面是加载的html:

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <link href="/assets/application-34af7785e9260ce67d287c5a05fc3583.css" media="all" rel="stylesheet" />
  <meta content="authenticity_token" name="csrf-param" />
  <meta content="MjhW2IjblGRfvIsAq/hphJT/WlFckUsQ/jSv8skdysk=" name="csrf-token" />
</head>
<body>
  hello

   <script>var require = {"baseUrl":"/assets","paths":{"application":"/assets/application-4d1052c11b8765cc7707a5f8643e33bf"},"priority":["application"],"shim":{"backbone-query-parameters":{"deps":["backbone"]},"jqm-config":{"deps":["jquery-mobile"]},"backbone":{"deps":["underscore","jquery"],"exports":"Backbone"}}};</script>
   <script data-main="application-4d1052c11b8765cc7707a5f8643e33bf" src="/assets/require-e48b9057622ee54d9d9b4dd773d4f295.js"></script>

</body>
</html>

你好
var require={“baseUrl”:“/assets”,“path”:“{“application”:“/assets/application-4d1052c11b8765cc7707a5f8643e33bf”},“priority”:[“application”],“shim”:{“backbone query parameters”:{“deps”:[“jquery mobile”]},“backbone”:{“deps”:[“下划线”,“jquery”],“exports”:“backbone”};

我猜错误在于如何在application.js中初始化我的应用程序,或者在requirejs.yml中的配置中,但我无法解决它。

解决了这个问题。在我的顶级javascript(application.js)中使用了
require
调用而不是
define
调用

您是否尝试过在本地但在生产模式下运行应用程序?很可能这会突出你在Heroku上看到的问题。我刚刚更新了这个问题以匹配这个场景。仍然没有解决办法。
<!DOCTYPE html>
<html>
<head>
  <title></title>
  <link href="/assets/application-34af7785e9260ce67d287c5a05fc3583.css" media="all" rel="stylesheet" />
  <meta content="authenticity_token" name="csrf-param" />
  <meta content="MjhW2IjblGRfvIsAq/hphJT/WlFckUsQ/jSv8skdysk=" name="csrf-token" />
</head>
<body>
  hello

   <script>var require = {"baseUrl":"/assets","paths":{"application":"/assets/application-4d1052c11b8765cc7707a5f8643e33bf"},"priority":["application"],"shim":{"backbone-query-parameters":{"deps":["backbone"]},"jqm-config":{"deps":["jquery-mobile"]},"backbone":{"deps":["underscore","jquery"],"exports":"Backbone"}}};</script>
   <script data-main="application-4d1052c11b8765cc7707a5f8643e33bf" src="/assets/require-e48b9057622ee54d9d9b4dd773d4f295.js"></script>

</body>
</html>