Bootstrap在rails应用程序中不起作用

Mos*_*ein 5 ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2

我无法打开我的应用程序,因为这个错误,我试图添加,// *= require "bootstrap-responsive"但这不起作用,我也试图从自定义中删除代码并将其添加到应用程序然后重命名应用程序application.css.scss,我试图重命名自定义custom.scss只有但我找不到任何有效的解决方案.我可以做什么 ?

Sass::SyntaxError at /
File to import not found or unreadable: bootstrap-responsive.
Load paths:
  Sass::Rails::Importer(/home/dexter/Desktop/Sherif/Triton/app/assets/stylesheets/custom.css.scss)
  /home/dexter/.rvm/gems/ruby-1.9.3-p194/gems/bootstrap-sass-3.0.2.1/vendor/assets/stylesheets
  (in /home/dexter/Desktop/Sherif/Triton/app/assets/stylesheets/custom.css.scss)
Run Code Online (Sandbox Code Playgroud)

Custom.css.scss

// Example using 'Spruce' bootswatch
//
// First import variables
@import "bootswatch/cerulean/variables";

// Then bootstrap itself
@import "bootstrap";

// Bootstrap body padding for fixed navbar
body { padding-top: 60px; }

// Responsive styles go here in case you want them
@import "bootstrap-responsive";

// And finally bootswatch style itself
@import "bootswatch/cerulean/bootswatch";

....
Run Code Online (Sandbox Code Playgroud)

Application.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 jquery.ui.all
 *= require bootstrap-datepicker
 *= require bootstrap-timepicker
 *= require bootstrap_form
 *= require style-metro
 *= require login
 *= require font
 *= require_tree .
 */
Run Code Online (Sandbox Code Playgroud)

Gemfile(我试图将bootstrap移出资产组,但我也没有解决错误)

group :assets do
  gem 'sass-rails', '3.2.4'
  gem 'bootstrap-sass', '~> 3.0.2.0'
...


end
Run Code Online (Sandbox Code Playgroud)

我的错误发生在我将项目推送到github然后再次克隆以使用它之后

Bil*_*han 18

自Bootstrap 3.0以来已删除Bootstrap-responsive.

3.0是移动优先设计,响应性现在是原生的.

删除那个require语句,现在不需要.

加成

Dexter(OP)终于通过回到2.3解决了这个问题.虽然这种情况很少见,但我认为可以吸取两个教训:

  1. 始终将版本添加到关键宝石.

  2. 始终使用bundle installbundle(默认安装).只有bundle update在真正需要的时候才使用,并且你做好了充分的准备.

  • 我不明白你为什么在3.0.2.0特别使用`bootstrap-sass` gem而你之前使用的是bootstrap 2?我猜你以前没有指定版本,但是在捆绑任务中更新了吗?如果是这样,您可以在2.3.2.0和`bundle install`分配bootstrap-sass,然后您将使用Bootstrap 2. (2认同)
  • 好吧我已经设置了'bootstrap-sass'2.3.2.0'`>`bundle install`>`rake tmp:clear`,如果你使用bootstrap 2.3,你可以将它添加到你的答案中,这样它可以帮助其他人:) (2认同)