私は HTML の内部の仕組みにあまり詳しくありません。私は Bootstrap に頼りすぎて、その魔法を働かせることができなかったので、ついに完全に困惑する場所を見つけました。アプリに接続しているデバイスの画面の解像度を検出するために、アプリのビューをレスポンシブにする必要があります。私のローカルマシンでは、これはうまくいきました。stylesheet_link_tag
以下に示すように、layout/application.html.haml
ファイルに3 番目とそれに続く行を追加しました%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