[英]Receiving error when installing bootstrap-sass gem in my ruby on rails app
I've been learning Ruby on Rails for the last few days and i'm following tutorials from a book.最近几天我一直在学习 Ruby on Rails,我正在学习一本书中的教程。 I'm working on an app which requires importing bootstrap however i'm having trouble installing it into my project.
我正在开发一个需要导入引导程序的应用程序,但是我无法将它安装到我的项目中。
I'm using Ruby version 2.3.1 and Rails version 5.1.1 and i'm using the cloud9 coding environment我使用的是 Ruby 版本 2.3.1 和 Rails 版本 5.1.1,我使用的是cloud9编码环境
I create a new app with the following command:我使用以下命令创建一个新应用程序:
rails new bootstrap_app
The next instruction is to "add the bootstrap gem to the gemfile" with the following command:下一条指令是使用以下命令“将 bootstrap gem 添加到 gemfile”:
gem 'bootstrap‐sass' , '~> 3.3.6'
I do this and I get the following error:我这样做了,但出现以下错误:
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command bootstrap-sass,
I looked up this error and I found it on stackoverflow here however "restarting the server" didn't work in my case.我抬头一看这个错误,我发现它计算器这里然而“重新启动服务器”在我的情况没有工作。
The next instruction in the tutorial, is the command本教程的下一条指令是命令
bundle install
I do this and it tells me a list of dependencies that are installed (bootstrap is not listed)我这样做,它告诉我已安装的依赖项列表(未列出引导程序)
I tried the command gem install bootstrap-sass
and it said it installed the gem successfully however when i try to import bootstrap in my CSS file as follows:我尝试了命令
gem install bootstrap-sass
并且它说它成功安装了 gem 但是当我尝试在我的 CSS 文件中导入 bootstrap 时,如下所示:
@import "bootstrap‐sprockets" ;
@import "bootstrap";
i get the following error:我收到以下错误:
ActionController::RoutingError (No route matches [GET] "/assets/bootstrap%E2%80%90sprockets"):
any ideas on how i can get this working?关于如何让这个工作的任何想法? Thanks
谢谢
As CD-RUM stated, you will need to add both the gem bootstrap-sass
& gem sass-rails
in to your Gemfile.正如 CD-RUM 所说,您需要将
gem bootstrap-sass
和gem sass-rails
到您的 Gemfile 中。 I would also suggest adding gem 'sprockets', '2.11.0'
as well since the newer version of sprockets that comes with rails 5 has had some issues working well with Bootstrap.我还建议添加
gem 'sprockets', '2.11.0'
,因为 Rails 5 附带的新版本的 sprockets 在 Bootstrap 上运行时遇到了一些问题。 Then run bundle install
.然后运行
bundle install
。
You will also want to rename your application.css
file to application.scss
and add the import files ( @import "bootstrap-sprockets"
& @import "bootstrap"
) there .您还需要将
application.css
文件重命名为application.scss
并在那里添加导入文件( @import "bootstrap-sprockets"
& @import "bootstrap"
)。 Now restart your server.现在重新启动您的服务器。
Read through the Ruby on Rails installation instructions here: bootsrap-sass gem & if you're still having issues consider changing the version of the bootstrap-sass gem to an earlier version (I use gem 'bootstrap-sass', '~> 3.3.5.1'
) since some people seem to experience version conflicts.在此处通读Ruby on Rails 安装说明: bootsrap-sass gem ,如果您仍有问题,请考虑将 bootstrap-sass gem 的版本更改为早期版本(我使用
gem 'bootstrap-sass', '~> 3.3.5.1'
) 因为有些人似乎遇到了版本冲突。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.