- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
此处引用 https://github.com/kalasjocke/sinatra-asset-pipeline/issues/42
你好,
我不能让它在生产中工作,而它在开发中工作正常
当我在生产中部署时,它会进行预编译,但不会加载 CSS。JS 加载正常,但没有 CSS。因此我有一个带有一些 JS 的 html 页面,但没有图像,没有 CSS。
我的 Assets 是这样组织的:
在本地开发环境中, Assets 在 public/assets/中预编译(使用 rake assets:precompile
)
在 Prod env 中,capistrano 任务是这样配置的:
after 'deploy:finishing', :finalize_update do
on roles(:web), in: :sequence do
execute(:chmod, '-R g+w', release_path) if fetch(:group_writable, true)
within release_path do
execute :rake, "assets:precompile RACK_ENV=production"
execute :rake, "assets:clean RACK_ENV=production"
end
end
end
Sinatra 应用程序(比如 myapp.rb)
# encoding: utf-8
require 'sinatra'
require 'haml'
require 'sass'
require 'compass'
require 'bootstrap-sass'
require 'sinatra/asset_pipeline'
Bundler.require
class MyApp < Sinatra::Base
set :assets_prefix, %w(assets vendor/assets)
set :assets_precompile, %w(app.js app.css *.png *.jpg *.svg *.eot *.ttf *.woff)
register Sinatra::AssetPipeline
...
应用.css
*= require application
应用程序.scss
@import "bootstrap/variables";
@import "bootstrap/mixins";
...
...
@import "layout";
布局:
%link{ href: '/assets/application.css', rel: 'stylesheet' }
...
%script{ src:'//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'}
%script{ src: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js' }
%script{ src: '/assets/app.js' }
雷克文件:
require 'sinatra/asset_pipeline/task'
require './lib/myapp'
Sinatra::AssetPipeline::Task.define! Novagile
我是否遗漏了一些简单明了的东西,或者这是一个恶意的配置技巧? :'(
最佳答案
很难说到底出了什么问题。绝对是您的布局或 View 的来源。请看working example .我只能猜测,您必须自己处理环境(production
或 development
)。我上面的例子是 view helper , 你可能会感兴趣。
关于css - Sinatra Assets 管道 - 不能使用链接到预编译的 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27152533/
您在 Sinatra 应用程序中使用什么验证码? 我喜欢 Google 的 http://www.google.com/recaptcha ,但似乎不适用于 Sinatra(不过有一个 Rails 插
如何从命令行将 Sinatra 应用作为守护程序运行? 它正在使用瘦: ruby app.rb -p 3000 -e production 我不喜欢在 app.rb 本身中设置它。我想从命令行取消它。
我正在使用 Sinatra 在 Ruby 中编写一个小型 Web 服务。使用 http 基本身份验证(在生产中通过 https)控制对几乎所有内容的访问。 我想从要求授权中排除一个特定的目录。是否有捷
我曾经能够在启动 sinatra 应用程序的窗口中看到为 sinatra 发出的 http 请求。 我认为在 sinatra 升级后我再也看不到它们了,我不知道如何做到这一点。我不需要将它们记录到文件
带有 activerecord gem 的 Sinatra 项目发出警告: DEPRECATION WARNING: Currently, Active Record suppresses error
我正在玩 Sinatra,我想让我的一条路线不区分大小写。我尝试添加这样的路线: get "(?i)/tileflood/?" do end 但它与预期的/tileflood 的任何排列都不匹配。我在
如果我没有在 Sinatra 中明确设置 session 过期时间,那么默认的过期时间是多少? 最佳答案 Sinatra session 来自 Rack::Session;所以开箱即用它默认为不过期。
似乎没有关于如何使用 Sinatra 中的 Rack::Protection 为表单启用 CSRF 保护的文档。有人做过这个吗?我似乎不知道如何告诉 Sinatra 启用此功能。 最佳答案 Sinat
假设我有一条 Sinatra 路线: put '/data' do request.body.read # ... end 看起来整个 request.body 都被读入内存了。有没有办法在主
我正在 Sinatra 中运行一个经典风格的应用程序,我想获取该应用程序绑定(bind)到的 URL。例如,如果我在开发环境中启动它,我希望得到:http://localhost:4567/,而在生产
我正在尝试在我的 Mac 上安装以下 ruby gem: http://www.sinatrarb.com/intro.html 我收到以下消息: michael-rosarios-mac
我最近更新到了 Ruby 1.9.2 (RVM)、Sinatra 1.1 和 Passenger 3.0.0。我有一个简单的应用程序,由以下部分组成: # config.ru require 'rub
似乎没有关于如何使用 Sinatra 中的 Rack::Protection 为表单启用 CSRF 保护的文档。有人做过这个吗?我似乎不知道如何告诉 Sinatra 启用此功能。 最佳答案 Sinat
与 sinatra 应用程序相比,Rack 应用程序有哪些优势? 谢谢 最佳答案 我认为提问者想要将它保留在 Rack 上的优点。 考虑到 Sinatra 已经是典型 Web 应用程序的极薄和简约的贴
我最近创建了一个带有登录表单(无基本身份验证)的 Sinatra 应用程序。为了防止在用户登录之前访问该应用程序,我在适当的位置放置了一个 before block before do unles
我如何设置 Sinatra 以便公用文件夹中的静态文件与响应 Access-Control-Allow-Origin = "*"一起返回? 最佳答案 在这里查看这个问题:Sinatra OPTIONS
我有一个基于 Sinatra 的 REST 服务应用程序,我想从其中一个路由中调用其中一个资源,从而有效地将一个资源与另一个资源组合在一起。例如 get '/someresource' do ot
我有一个使用经典 Sinatra 的旧项目(不是模块化 我在互联网上能找到的唯一使用 Puma 的示例是使用模块化 Sinatra。 引用:http://www.sinatrarb.com/intro
问题是默认处理程序是在 中定义的。 Sinatra::ShowExceptions ,由 控制:raise_errors 配置设置,这个设置是全有或全无。如果 :raise_errors 关闭然后 错
我有以下 Sinatra 应用程序,我正在测试 error阻止但它似乎不起作用。 这是我的 sinatra 应用程序: require 'rubygems' require 'sinatra' err
我是一名优秀的程序员,十分优秀!