简体   繁体   English

Bootstrap 在我的 rails 项目中是错误的版本

[英]Bootstrap is wrong version in my rails project

I am going through a rails Udemy course, and we are using bootstrap.我正在学习 Rails Udemy 课程,我们正在使用引导程序。 The instructor is on an older version and I started using the most recent version.讲师使用的是旧版本,我开始使用最新版本。 Before long I discovered they are very different, so I wanted to switch to the correct version for the project.不久之后,我发现它们非常不同,所以我想为项目切换到正确的版本。 I have done gem uninstall gem bootstrap, and rails assets:clean, and went as far as to switch back to main and delete that git branch.我已经完成了 gem 卸载 gem bootstrap 和 rails assets:clean,并切换回 main 并删除了 git 分支。 I then updated the gemfile to install bootstrap 4.0.0, and ran bundle install.然后我更新了 gemfile 以安装 bootstrap 4.0.0,并运行 bundle install。 Gemfile lock reflects the changes. Gemfile 锁反映了更改。 I then copied the instructors provided source files for the views we had been working on and the application.scss file.然后,我复制了讲师为我们一直在处理的视图和 application.scss 文件提供的源文件。 It has not worked.它没有奏效。 The scss in the rails app is being completely overridden by some trace of bootstrap 5.2. rails 应用程序中的 scss 被引导程序 5.2 的一些痕迹完全覆盖。 I know this because I inspected the page in the chrome dev console and in the sources there is this link which references the version.我知道这一点是因为我在 chrome 开发控制台中检查了该页面,并且在源代码中有这个链接引用了该版本。

/* line 1, ../../.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootstrap-5.2.0/assets/stylesheets/bootstrap/_root.scss */ /* 第 1 行,../../.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootstrap-5.2.0/assets/stylesheets/bootstrap/_root.scss */

I have restarted the rails server multiple times, but there is no effect.我已经多次重新启动rails服务器,但没有任何效果。 I have navigated to that folder in the rbenv directory and the bootstrap-4.0.0.alpha6 version is listed there, not the 5.2.0.我已经导航到 rbenv 目录中的那个文件夹,并且那里列出了 bootstrap-4.0.0.alpha6 版本,而不是 5.2.0。 However, the 5.2.0 version is persisting in what is on the browser.但是,5.2.0 版本保留了浏览器上的内容。 No changes that I make in the scss file have any effect.我在 scss 文件中所做的任何更改都没有任何效果。 I tried changing all the colors to random ones, but none show up.我尝试将所有 colors 更改为随机的,但没有出现。 There are no error messages to share.没有要分享的错误消息。 The CSS simply has no effect and appears to be overridden by this file that I cannot find anywhere in my rails project or on my system. CSS 根本没有效果,并且似乎被这个文件覆盖,我在我的 rails 项目或系统中的任何地方都找不到该文件。 Thank your for any guidance to fix this.感谢您提供任何解决此问题的指导。

I found an answer.. I had to use rake assets:clobber to clear out pre-confiled files that had the bootstrap 5.2.0 in them.我找到了答案。我不得不使用 rake assets:clobber 来清除其中包含引导程序 5.2.0 的预配置文件。 I did that and then rake assets:pre-confile and it instantly fixed it.我这样做了,然后 rake assets:pre-confile 并立即修复它。

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

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