Rails 的脚手架 - 引导应用程序
Posted
技术标签:
【中文标题】Rails 的脚手架 - 引导应用程序【英文标题】:Scaffold by Rails - Bootstrap application 【发布时间】:2019-07-21 17:26:45 【问题描述】:有人知道如何通过选择 gem 'rails', '5.2.0' 和 'bootstrap', '4.3.1' 来解决脚手架问题,这可能是由于无法制作 scaffold.scss 文件。
我对Rails的了解太少,无法理解执行结束时的解释:
rails generate scaffold Something first second
最终脚手架被打破并解释:
1.使用 bootsnap
...
invoke scss
create app/assets/stylesheets/somethings.scss
/usr/local/rvm/gems/ruby-2.4.3/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require': cannot load such file -- sass/css (LoadError)
from /usr/local/rvm/gems/ruby-2.4.3/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
from /usr/local/rvm/gems/ruby-2.4.3/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:80:in `register'
...
2。没有 bootsnap
...
invoke scss
create app/assets/stylesheets/somethings.scss
/usr/local/rvm/gems/ruby-2.4.3/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require': cannot load such file -- sass/css (LoadError)
from /usr/local/rvm/gems/ruby-2.4.3/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
from /usr/local/rvm/gems/ruby-2.4.3/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
...
【问题讨论】:
【参考方案1】:我在尝试运行 rails generate scaffold --help
时遇到了类似的错误。是
.../ruby-2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require': cannot load such file -- sass/css (LoadError)
我的 Gemfile 中没有 bootsnap,但我有 sassc-rails gem。
# Use SCSS for stylesheets
gem 'sassc-rails', '~> 2.1'
sassc-rails 的最新版本是 2.1.2。尝试运行bundle update sassc-rails
。这就是为我解决的问题。
【讨论】:
以上是关于Rails 的脚手架 - 引导应用程序的主要内容,如果未能解决你的问题,请参考以下文章