这应该很简单,但它根本就不起作用。使用sinatra-assetpack运行Padrino。所有的css文件都是这样服务的:
serve '/stylesheets', from: '/app/stylesheets'
css :shared, [
'/stylesheets/reset.css',
'/stylesheets/runemadsen.css'
]但是,当尝试提供.js文件时,它不起作用。我在脚本加载中得到了404:
serve '/javascripts', from: '/app/javascripts'
js :shared, [
'/javascripts/jquery.js'
]我真的不明白。这是完全相同的代码。文件就在那里。有什么建议吗?
发布于 2012-03-12 19:24:42
不确定这个问题,但是你能让基本的方法工作吗?serve '/javascripts', from: '/app/javascripts'部件是可选的。在Readme中,只使用javascript:
require 'sinatra/assetpack'
class App < Sinatra::Base
set :root, File.dirname(__FILE__)
register Sinatra::AssetPack
assets {
# The second parameter defines where the compressed version will be served.
# (Note: that parameter is optional, AssetPack will figure it out.)
js :app, '/js/app.js', [
'/js/vendor/**/*.js',
'/js/app/**/*.js'
]
}
end值得注意的是,我的assets代码块如下所示:
assets {
js :main, [
'/js/jquery.js',
'/js/application.js',
]其中jquery位于public/js,application.coffee位于app/js。我的布局(haml)中的脚本标记是=js :main。
https://stackoverflow.com/questions/8453983
复制相似问题