前提
windows10
Linux
Ubuntu
ruby 2.5.1p57
Rails 5.2.3
エラー発生前に行ったこと
参考書を手本に、app/assets/stylesheets/application.css を削除し、同じ場所に application.scss を 作成。
@import "bootstrap";
routes.rb
Rails.application.routes.draw do root to: 'tasks#index' resources :tasks # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end
発生している問題・エラーメッセージ
root to: 'tasks#index' に接続するとエラーが出る。(root to:'tasks#index' を削除するとエラーは出ず、Rails初期画面が表示される)
sayuiso@DESKTOP-OQI08IQ:~/railsTest/taskleaf1$ bin/rails s => Booting Puma => Rails 5.2.3 application starting in development => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.12.1 (ruby 2.5.1-p57), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://localhost:3000 Use Ctrl-C to stop Started GET "/" for ::1 at 2019-07-18 09:12:27 +0900 (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC ↳ /home/sayuiso/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98 Processing by TasksController#index as HTML Rendering tasks/index.html.slim within layouts/application Rendered tasks/index.html.slim within layouts/application (11.4ms) Completed 500 Internal Server Error in 179ms (ActiveRecord: 0.0ms) ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.): 5: | Taskleaf1 6: = csrf_meta_tags 7: = csp_meta_tag 8: = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' 9: = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' 10: body 11: .app-title.navbar.navbar-expand-md.navbar-light.bg-light app/views/layouts/application.html.slim:8:in `_app_views_layouts_application_html_slim___1312250699688542821_70368279940180'
該当のソースコード
doctype html html head title | Taskleaf1 = csrf_meta_tags = csp_meta_tag = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' body .app-title.navbar.navbar-expand-md.navbar-light.bg-light .navbar-brand Taskleaf1 .container = yield
Gemfile
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.5.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.1' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'slim-rails' gem 'html2slim' gem 'bootstrap'
試したこと
参考書には scss は最終的に cssファイルに変換されると書いてあるので、なぜエラーが起きているのかわかりません。結果的にcss
ファイルはあるじゃない! 同一のエラー内容で検索したところ、本番環境ではプリコンパイルが必要であるとありましたが、私はまだ開発段階(参考書では下準備)なので関係はないのかなと思いました。
リンク内容の記事で、私と同じエラーが掲載されていますが、具体的な解決方法に触れられていませんでした。
補足情報
足りない情報ありましたら、教えてください。