Как получить bootstrap-sass для загрузки в Rails 6 (Mac OSX) - PullRequest
0 голосов
/ 11 октября 2019

Я использую Rails 6 для курса Udemy Complete Rails, который основан на Rails 4 с некоторыми примечаниями для Rails 5, но ничего для Rails 6.

Я получаю сообщение об ошибке "ActionView :: Template:: Ошибка (Ошибка: Файл для импорта не найден или не читается: bootstrap-sprockets. В строке 3: 1 файла app / assets / stylesheets / custom.css.scss

@ import 'bootstrap-sprockets '; "

Существует множество полезных статей, касающихся проблем с начальной загрузкой, но ни одно из предложенных решений не решает эту проблему.

Файл Gem:


        Source 'https://rubygems.org'
        git_source(:github) { |repo| "https://github.com/#{repo}.git" }

        #  Last modified 11 October 2019 - and again after merging branch
        repository

        ruby '2.6.5'
            gem 'rails', '~> 6.0.0'

        # Use sqlite3 as the database for Active Record
        # Use Puma as the app server

        gem 'bcrypt', '~> 3.1.7'
        gem 'puma', '~> 3.11'

        group :assets do
            #   gem 'coffee-rails', '~> 3.2.2'   # causing issue with missing
            railties gem
            gem 'uglifier', '>= 1.2.4'
            gem 'bootstrap-sass', '~> 3.4.1'
            gem 'sassc-rails', '>= 2.1.0'
            gem 'jquery-rails'
        end

        gem 'webpacker', '~> 4.0'
        gem 'turbolinks', '~> 5'    
        gem 'jbuilder', '~> 2.7'
        # gem 'redis', '~> 4.0'
        # Use Active Model has_secure_password

        # gem 'image_processing', '~> 1.2'    
        gem 'bootsnap', '>= 1.4.2', require: false

        group :development, :test do
          gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
        end

        group :development do
            gem 'sqlite3', '~> 1.4'
            gem 'web-console', '>= 3.3.0'
            gem 'listen', '>= 3.0.5', '< 3.2'
            gem 'spring'
            gem 'spring-watcher-listen', '~> 2.0.0'
        end

        group :test do
          gem 'capybara', '>= 2.15'
          gem 'selenium-webdriver'
          gem 'webdrivers'
        end

        group :production do
            gem 'pg'
        end

    custom.css.scss
    ~~~
        $navbar-default-bg: black;
        @import 'bootstrap-sprockets';
        @import 'bootstrap'; # replaces @import 'bootstrap-sass'

Извлечение журнала ошибок:

    app/assets/stylesheets/custom.css.scss:3
    app/views/layouts/application.html.erb:7
    Started GET "/articles" for ::1 at 2019-10-12 09:29:21 +1100
    Processing by ArticlesController#index as HTML
      Rendering articles/index.html.erb within layouts/application
      [1m[36mArticle Load (0.1ms)[0m  [1m[34mSELECT "articles".* 
      FROM "articles"[0m
      ↳ app/views/articles/index.html.erb:11
      Rendered articles/index.html.erb within layouts/application  
     (Duration: 1.9ms | Allocations: 1209)
     Completed 500 Internal Server Error in 6ms (ActiveRecord: 0.1ms | 
     Allocations: 4772)

    ActionView::Template::Error (Error: File to import not found or 
    unreadable: bootstrap-sprockets.  on line 3:1 of 
    app/assets/stylesheets/custom.css.scss
    >> @import 'bootstrap-sprockets'; 
       4: <title>AlphaBlog5.1.4</title>
        5: <%= csrf_meta_tags %>
        6: 
        7: <%= stylesheet_link_tag    'application', media: 'all',
          'data-turbolinks-track': 'reload' %>
        8: <%= javascript_include_tag 'application',
           'data-turbolinks-track': 'reload' %>
        9: </head>
       10: 

    app/assets/stylesheets/custom.css.scss:3
    app/views/layouts/application.html.erb:7
    Started GET "/" for ::1 at 2019-10-12 09:29:22 +1100
    Processing by PagesController#home as HTML
      Rendering pages/home.html.erb
      Rendered pages/home.html.erb (Duration: 18.9ms | Allocations: 6719)
    Completed 500 Internal Server Error in 28ms (ActiveRecord: 0.0ms | Allocations: 8121)

    Started GET "/" for ::1 at 2019-10-12 09:29:23 +1100
    Processing by PagesController#home as HTML
      Rendering pages/home.html.erb
      Rendered pages/home.html.erb (Duration: 5.5ms | Allocations: 4159)
    Completed 500 Internal Server Error in 7ms (ActiveRecord: 0.0ms |
       Allocations: 4655)   
    Started GET "/" for ::1 at 2019-10-12 09:53:16 +1100
      [1m[35m (0.4ms)[0m  [1m[34mSELECT sqlite_version(*)[0m
      [1m[35m (0.1ms)[0m  [1m[34mSELECT "schema_migrations"."version" 
       FROM "schema_migrations" ORDER BY "schema_migrations"."version" 
        ASC[0m
      Processing by PagesController#home as HTML
      Rendering pages/home.html.erb
      Rendered pages/home.html.erb (Duration: 56.8ms | Allocations: 
        21911)
    Completed 500 Internal Server Error in 65ms (ActiveRecord: 0.0ms | 
    Allocations: 24301)

application.js:

    //= require jquery
    //= require jquery_ujs
    //= require rails-ujs
    //= require turbolinks
    //= require bootstrap-sprockets
    //= require_tree

Ошибка сервера:

   Processing by PagesController#home as HTML
    Rendering pages/home.html.erb
    Rendered pages/home.html.erb (Duration: 56.8ms | Allocations: 21911)
    Completed 500 Internal Server Error in 65ms (ActiveRecord: 0.0ms | 
    Allocations: 24301)
...