I created a new fresh project in Rails 7, and whenever I use the generating script
rails generate scaffold
or rails generate controller
, all of the generated files are created except the css/scss.
Apparently, I'm not the only one with the issue
There's a claim on that link that in Rails 7, the CSS files are not generated by default.
Is there a way to force rails CLI to generate styles on the scaffold command?
And in anyway, why did they make that change in Rails 7, if the claim is true?
Here's the script I ran and the output in my given console:
rails g scaffold WhyNoCss dont_work:boolean
invoke active_record
create db/migrate/20220215221757_create_why_no_csses.rb
create app/models/why_no_css.rb
invoke test_unit
create test/models/why_no_css_test.rb
create test/fixtures/why_no_csses.yml
invoke resource_route
route resources :why_no_csses
invoke scaffold_controller
create app/controllers/why_no_csses_controller.rb
invoke erb
create app/views/why_no_csses
create app/views/why_no_csses/index.html.erb
create app/views/why_no_csses/edit.html.erb
create app/views/why_no_csses/show.html.erb
create app/views/why_no_csses/new.html.erb
create app/views/why_no_csses/_form.html.erb
create app/views/why_no_csses/_why_no_css.html.erb
invoke resource_route
invoke test_unit
create test/controllers/why_no_csses_controller_test.rb
create test/system/why_no_csses_test.rb
invoke helper
create app/helpers/why_no_csses_helper.rb
invoke test_unit
invoke jbuilder
create app/views/why_no_csses/index.json.jbuilder
create app/views/why_no_csses/show.json.jbuilder
create app/views/why_no_csses/_why_no_css.json.jbuilder
Is there a way to force rails CLI to generate styles?
While you can add --css sass
(also: tailwind
, postcss
, bootstrap
) to rails new
commands, the ability to generate CSS files with a scaffold
command was removed in v7.0.0.alpha1
( PR , commit ).
And in anyway, why did they make that change in Rails 7, if the claim is true?
You can read the justification on the PR in addition to their blog post on Rails 7 that mentions CSS changes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.