0

私のgemfileでバージョン2.3.1.0を指定して、bootstrap-sass gemを使用して、Bootstrap 2.3で始まったプロジェクトに取り組んでいます。Bootstrap 3にアップデートしたいです。

これは、bootstrap-sass gem バージョン 2.3.1.0 でのアプリの外観です。

ここに画像の説明を入力

スタイルを Bootstrap 3 に更新する実験のためにブランチをチェックアウトしたので、最新バージョンの bootstrap-sass gem を使用するように gemfile を更新し、bundle update を実行してインストールしました。

上記の "Amazing Point" div 要素のそれぞれにブートストラップ 3 バージョン クラスがあるため、ヒーロー ユニットのスタイルは消え、ボタンはフラットになり、Amazing ポイントは "col-lg" で 4 列にまたがるはずです。 -4" クラスを指定しました。

しかし、Rails サーバーを起動すると、Bootstrap 2.3 と 3 が混在しています。

ここに画像の説明を入力

「col-lg-4」クラスは Amazing Points に適用されますが、サインイン ボタンとサインアップ ボタンは Bootstrap 2.3 ボタンのように見えます。また、「サインイン」と「サインアップ」のテキストに微妙ではあるが目に見える変更があり、少し太字になっています。Bootstrap 2.3 と 3 の奇妙なハイブリッドが進行中のようです。

しかし、rake assets:precompile を実行すると、次のような結果が得られます。

ここに画像の説明を入力

正しく表示されるようになりました。

しかし、正しく動作させるために常に rake assets:precompile を実行しなければならないのはなぜですか? そして、gem ファイルを切り替えたときに自動的に更新されるようにするにはどうすればよいでしょうか?

その他の関連ファイルは次のとおりです。

アプリケーション.css:

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* 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 bootstrap
*= require_tree .
*/

Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'jquery-rails'
gem 'devise'

group :production do
   gem 'pg'
end

group :development do
  gem 'sqlite3'
end

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'bootstrap-sass', '3.0.2.0'
end

Gemfile.lock (bootstrap-sass バージョンのみを示します):

bootstrap-sass (3.0.2.0)
  sass (~> 3.2)

アプリケーション.rb:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

module Bloccit
  class Application < Rails::Application

  config.encoding = "utf-8"

  # Configure sensitive parameters which will be filtered from the log file.
  config.filter_parameters += [:password]

  # Enable escaping HTML in JSON.
  config.active_support.escape_html_entities_in_json = true

  config.active_record.whitelist_attributes = true

  # Enable the asset pipeline
  config.assets.enabled = true

  # Version of your assets, change this if you want to expire all your assets
  config.assets.version = '1.0'

  config.assets.initialize_on_precompile = false
  end
end

config/development.rb の関連する行:

# Do not compress assets
config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = true

config.assets.compile = true

config.serve_static_assets = false
4

1 に答える 1