ruby-on-rails - Bootstrap 在 Rails 应用程序中不起作用

标签 ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2

由于此错误,我无法打开我的应用程序,我尝试添加 // *= require "bootstrap-responsive"但这不起作用,我也尝试从自定义中删除代码并将其添加到应用程序中,然后将应用程序重命名为 application.css.scss ,我尝试将 custom 重命名为 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)

自定义.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";

....

应用程序.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 .
 */

Gemfile(我试图将 bootstrap 移出 Assets 组,但我也没有解决错误)
group :assets do
  gem 'sass-rails', '3.2.4'
  gem 'bootstrap-sass', '~> 3.0.2.0'
...


end

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

最佳答案

自 Bootstrap 3.0 起,Bootstrap-responsive 已被移除。

3.0 是移动优先设计,响应能力现在是原生的。

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

添加

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

  • 始终将版本添加到关键 gem。
  • 始终使用 bundle installbundle (默认安装)。仅使用 bundle update当确实有必要并且您已做好充分准备时。
  • 关于ruby-on-rails - Bootstrap 在 Rails 应用程序中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19948584/

    相关文章:

    ruby-on-rails - 简单表单 - 翻译输入字段的选项

    ruby-on-rails-3 - 导轨 : ActiveRecord Query for has_many :through model

    ruby-on-rails - 对于 Rails,如何访问或打印配置变量(作为实验或测试/调试)

    ruby-on-rails - Rails 3 操作邮件程序制作 OpenSSL::SSL::SSLError: 主机名与服务器证书不匹配

    ruby-on-rails - 任何人都有 Ruby on Rails 的 SEO 技巧

    ruby-on-rails - 在 Ruby 文件中查找所有 undefined variable ?

    ruby-on-rails - Ruby on Rails 上的 JSON api

    ruby - 在 Rails 3 中扩展 Enumerable

    ruby-on-rails - rails 模型 : includes method on self

    ruby-on-rails - Rails 迁移总是在模式中插入空格或更改列的顺序