【发布时间】:2012-02-16 07:06:13
【问题描述】:
大家好,
我对 jQuery Datepicker 和 Rails 3.1 感到非常沮丧。 它在我的开发环境中完美运行,但在 Heroku/Cedar 的生产环境中无法运行。当我选择我的日期字段时,它根本不会弹出。
这就是我到目前为止所做的:
我将 jquery 文件放入 \apps\assets\javascript:
- jquery-1.7.1.min.js
- jquery-ui-1.8.17.custom.min.js
- jquery.ui.datepicker-de.js
我将它们与其他文件一起添加到我的 production.rb:
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) <br />
config.assets.precompile += %w( event_calendar.js event_calendar.css jquery-1.7.1.min.js jquery-ui-1.8.17.custom.min.js jquery-ui-1.8.17.custom.css jquery.ui.datepicker-de.js)
然后我在本地 as described here 预编译了我的资产,它们正确地出现在 /public/assets/ 和我的 manifest.yml 中。所以一切看起来都很好,在将我的应用程序推送到 Heroku 时我没有收到任何错误,但是当我选择与 datepicker 关联的文本字段时,没有任何反应,它根本不会显示。
您有什么想法吗?
我怎样才能找出问题所在?
在 Heroku 日志中,我只能找到这样的条目:
cache: [GET /assets/application-58ec8ec4b5384a8fb8d7884169385e49.css] miss
如果有人可以提供帮助,我会很高兴。
更新:
这是我的application.js:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require_tree .
$(document).ready(
function()
{
$("#picker").datepicker($.datepicker.regional['de']);
$("#picker").datepicker();
}
);
据我所知,//= require_tree . 负责将所有 javascript 文件包含在 assets 文件夹中,例如 \app\assets\javascripts\。这是否包括\public\assets 中的预编译资产?
这是我的application.css:
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
...
同样,我认为*= require_tree . 负责\app\assets\stylesheets 以及\public\assets,我的预编译样式表所在的位置。
这里是heroku上应用的链接,选择日期字段应该会弹出日历:
http://smooth-window-1858.herokuapp.com/events/new
【问题讨论】:
-
你试过在生产模式下运行的本地机器上调试这个吗?
-
我现在这样做了,我发现the parameter config.serve_static_assets 可能是我的问题。
标签: ruby-on-rails-3.1 heroku asset-pipeline jquery-ui-datepicker