【问题标题】:Bootstrap not work in rails applicationBootstrap 在 Rails 应用程序中不起作用
【发布时间】:2013-11-13 08:12:09
【问题描述】:

由于此错误,我无法打开我的应用程序,我尝试添加 // *= 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(我试图将引导程序移出资产组,但我也没有解决错误)

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


end

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

【问题讨论】:

  • 你确定你有引导响应文件吗?
  • 我没有,推送到 git 之前的版本没有问题

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


【解决方案1】:

Bootstrap-responsive 自 Bootstrap 3.0 以来已被移除。

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

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

加法

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

  1. 始终将版本添加到关键 gem。

  2. 始终使用bundle installbundle(默认安装)。仅在确实需要并且您已做好充分准备时才使用bundle update

【讨论】:

  • 当我删除它时,它会因为 @import "bootstrap" 而引发错误,删除它也会告诉我未定义的 mixin box-shadow,对此有什么帮助吗?
  • 如果swatch是2.3的,恐怕3.0就不能用了,因为所有的变量名都改了。您可以在这里查看详细信息:getbootstrap.com/getting-started/#migration
  • 好的,我该怎么做才能使样本再次使用 2.3 工作?因为在推送到 github 之前一切正常
  • 我不明白为什么你在 3.0.2.0 有 bootstrap-sass gem 但你之前使用的是 bootstrap 2?我猜您之前没有指定版本,但是在捆绑任务中对其进行了更新?如果是这样,您可以在 2.3.2.0 和 bundle install 分配 bootstrap-sass,然后您将使用 Bootstrap 2。
  • 好的,我已经设置了 bootstrap-sass '2.3.2.0' > bundle install > rake tmp:clear ,如果您使用引导程序 2.3,您能否将其添加到您的答案中,以便它可以帮助其他人:)
猜你喜欢
  • 2014-01-13
  • 2018-02-10
  • 2012-11-02
  • 1970-01-01
  • 1970-01-01
  • 2019-01-23
  • 2013-06-05
  • 1970-01-01
  • 2019-06-28
相关资源
最近更新 更多