Rails 4 + bootstrap set up assets

前端 未结 8 1521
春和景丽
春和景丽 2021-02-04 06:53

I am trying to setup bootstrap on Rails4 using bootstrap-sass and I am getting this famous error:

Sprockets::FileNotFound - couldn         


        
8条回答
  •  南方客
    南方客 (楼主)
    2021-02-04 07:23

    The fix for me was two parts ... my correct list first ... but the list alone wasn't the fix!

    gem 'sass-rails', '~> 5.0'
    gem 'bootstrap-sass', '~> 3.3.0'
    gem 'uglifier', '>= 1.3.0'
    gem 'coffee-rails', '~> 4.1.0'
    

    Then I had a gemfile.Lock issue ... if anyone else can't get the files to load & doesn't want to use the CDN...check your gemfile.Lock & see what versions are compiled off the gemfile (one is input for us as dev's & the other is what is actually ran by the framework - it will cause issues if you try to modify gemfile.lock).

    To resolve the gemfile lock...close the gemfile & gemfile.Lock

    1. I had to first delete the items in question from the "gemfile".
    2. I did a "gem install " I wanted for each of them.

    Then open the gemfile & gemfile.Lock to check results. Note, you still have to do all the configuration bootstrap etc requires for each of these. It doesn't hurt to run a rails assets:precompile either.

    Note: The rails assets:precompile is a rails 5 command.

提交回复
热议问题