简体   繁体   English

如何从使用twitter-Bootstrap-rails gem切换为使用普通Bootstrap

[英]How do I switch from using the twitter-Bootstrap-rails gem to using normal Bootstrap

I have a rails app that was built with the Bootstrap rails gem for development, but now I am going to start doing design and styling stuff and I would rather just move to referencing bootstrap normally/locally. 我有一个用Bootstrap rails gem开发的Rails应用程序,但是现在我要开始进行设计和样式设计,而我宁愿只是正常/本地引用Bootstrap。 The app is based on the rails3-bootstrap-devise-cancan template . 该应用程序基于rails3-bootstrap-devise-cancan模板

I tried just removing the bootstrap-sass gem and then deleting all of the stylesheets and .js files in /assets, and replacing the application.css and application.js with bootstrap.css and bootstrap.js. 我尝试仅删除bootstrap-sass gem,然后删除/ assets中的所有样式表和.js文件,并用bootstrap.css和bootstrap.js替换application.css和application.js。 But when I launch the application, I can see it is grabbing certain things from bootstrap, but the formatting is wrong and a lot of interface things don't work. 但是,当我启动该应用程序时,我可以看到它正在从引导程序中获取某些内容,但是格式错误并且许多接口功能都无法正常工作。

What is the easiest cleanest way to make the switch? 进行切换的最简单最干净的方法是什么?

source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'sqlite3'
gem 'mysql2'
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
gem "rspec-rails", ">= 2.12.2", :group => [:development, :test]
gem "database_cleaner", ">= 1.0.0.RC1", :group => :test
gem "email_spec", ">= 1.4.0", :group => :test
gem "cucumber-rails", ">= 1.3.1", :group => :test, :require => false
gem "launchy", ">= 2.2.0", :group => :test
gem "capybara", ">= 2.0.3", :group => :test
gem "factory_girl_rails", ">= 4.2.0", :group => [:development, :test]
gem "bootstrap-sass", ">= 2.3.0.0"
gem "devise", ">= 2.2.3"
gem "cancan", ">= 1.6.9"
gem "rolify", ">= 3.2.0"
gem "simple_form", ">= 2.1.0"
gem "quiet_assets", ">= 1.0.2", :group => :development
gem "figaro", ">= 0.6.3"
gem "better_errors", ">= 0.7.2", :group => :development
gem "binding_of_caller", ">= 0.7.1", :group => :development, :platforms => [:mri_19, :rbx]
gem 'execjs'
gem 'jquery-rails'
gem 'jquery-ui-rails'

The bootstrap-less gem should not affect the files in your own app/assets folder, instead they are fetched from each gem's corresponding folders. bootstrap-less gem不会影响您自己的app/assets文件夹中的文件,而是从每个gem的相应文件夹中获取它们。 My guess is that the CSS/JS assets you deleted were not put there by the gem, but by you or someone else working on the project. 我的猜测是,您删除的CSS / JS资产不是由gem放置的,而是由您或从事此项目的其他人放置的。

Instead of replacing application.css and application.js with the Bootstrap files, you should add them to your assets folder and import them into the application files. 不应使用Bootstrap文件替换 application.cssapplication.js ,而应将它们添加到资产文件夹并将其导入应用程序文件。 Thus, if you have any other assets, they can too be imported into the same files. 因此,如果您有任何其他资产,也可以将它们导入相同的文件中。

Usually, all files in the same folder are automatically imported. 通常,同一文件夹中的所有文件都会自动导入。 My application.css by default includes this comment which instructs it to include all CSS files in the same directory tree: 默认情况下,我的application.css包含以下注释,指示其将所有CSS文件包括在同一目录树中:

 *= require_tree .

You should probably read up on how the Asset Pipeline works , that makes it easier to find out where the problem lies. 您可能应该阅读Asset Pipeline的工作原理 ,从而更容易发现问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM