Error: Undefined variable: "$alert-padding-y"
Asked Answered
W

1

5

I am using ruby 2.4.1 and rails 5.2.2, I want to add bootstrap 4 to my existing project. I removed all the css and js files from assets and just imported bootstrap in my application.scss and required in application.js file. But when page is opened it is giving error:

ActionView::Template::Error (Error: Undefined variable: "$alert-padding-y". on line 7 of ../../.rvm/gems/ruby-2.4.1/gems/bootstrap-4.2.1/assets/stylesheets/bootstrap/_alert.scss

padding: $alert-padding-y $alert-padding-x;

Wergild answered 7/1, 2019 at 7:25 Comment(6)
check if you have config.assets.precompile = ['.js', '.css', '*.css.erb'] in application.rbMissymist
@AsnadAtta Yes i have config.assets.precompile += %w( *.js *.css *.jpg *.png) in application.rbWergild
did you removed sass gem from gemfile?Sitology
No @Sitology gem 'sass-rails' is there in my gem file.Wergild
please provide application.scss fileMissymist
Thanks all for the help. I just used my required file to be precompiled instead of * in config.assets.precompile += %w( *.js *.css *.jpg *.png). Error gone, that means there is some file conflicting with bootstrap 4. I am trying to find the conflict now.Wergild
M
6

You should add your asset file in config.assets.precompile = ['.js', '.css', '*.css.erb'] in application.rb. and check if you have import sprockets in application.scss

Missymist answered 9/1, 2019 at 10:26 Comment(1)
Weirdly for me, it worked after I unwittingly downgraded sprockets-rails by following github.com/twbs/bootstrap-rubygem Ensure that sprockets-rails is at least v2.3.2 bit. I did a bundle show sprockets-rails and it said 3.2.1, I missed that the major version was higher, assumed it was a new version and changed it, it worked, but through a 3.2.1 => 2.3.2 downgrade in sprockets-rails.Rig

© 2022 - 2024 — McMap. All rights reserved.