我不太熟悉 HTML 的内部工作原理。我过于依赖 Bootstrap 来为我发挥它的魔力,所以我终于找到了一个让我完全难过的地方。我需要让我的应用程序的视图响应检测连接到它的设备屏幕的分辨率。在我的本地机器上,效果很好。我将第三个添加stylesheet_link_tag
到我的layout/application.html.haml
文件中,如下所示,以及%meta
它后面的行。
!!!
%html
%head
%title WallyWorld
= stylesheet_link_tag "application", :media => "all"
= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
= stylesheet_link_tag "assets/css/bootstrap-responsive.css", :rel => 'stylesheet/less'
= javascript_include_tag "application"
= csrf_meta_tags
%meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}
%body
// The rest...
再说一次,很多这对我来说没有意义。尽我所能遵循文档。
这在我的本地机器上一切正常。但是,当我在生产机器上cap deploy
启动unicorn
服务器时,出现以下错误:
2013-08-06 12:57:54 FATAL --
ActionView::Template::Error (assets/css/bootstrap-responsive.css isn't precompiled):
4: %title WallyWorld
5: = stylesheet_link_tag "application", :media => "all"
6: = stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
7: = stylesheet_link_tag "assets/css/bootstrap-responsive.css", :rel => 'stylesheet/less'
8: = javascript_include_tag "application"
9: = csrf_meta_tags
10: %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}
app/views/layouts/application.html.haml:7:in `_app_views_layouts_application_html_haml__3068307506204356330_32376380'
好,很好。bootstrap-responsive.css
没有预编译。好吧,我实际上不知道如何手动执行此操作。我尝试按照本文的建议下载我自己的自定义版本的 Bootstrap ,但我现在更加困惑。我根本不知道如何让这些东西发挥作用。
关于使这些东西工作的实际过程是什么的任何建议或解释都会很棒。奇怪的是,很难找到一个解释,至少在我能理解的方面。
==== 编辑添加到 production.rb ====
Wallyworld::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
# Defaults to nil and saved in location specified by config.assets.prefix
# config.assets.manifest = YOUR_PATH
# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# See everything in the log (default is :info)
# config.log_level = :debug
# Prepend all log lines with the following tags
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w( assets/css/bootstrap-responsive.css )
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
end