can anyone help me? I already did everything to install Bootstrap on my Ruby on Rails application, however continues to appear without bootstrap format.
I have Rails 4.2.5.1
in gemfile I added, and ran bundle install
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
in app/assets/stylesheets I have application.scss with:
#import "bootstrap-sprockets";
#import "bootstrap";
and in assets/javascript I have application.js with:
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require_tree .
Please, follow these instructions:
Include following gems in your Gemfile
gem 'twitter-bootstrap-rails', git: 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'therubyracer'
gem 'less-rails'
Run the following commands:
bundle
rails g bootstrap:install less
Reference: https://github.com/seyhunak/twitter-bootstrap-rails
Related
I have tried every tutorial and every guide but I am not able to integrate bootstrap in my rails app
I have tried bootstrap-sass gem, bootstrap CDN, bootstrap gem
Ruby on Rails version
5.2.0
Ruby version 2.2.6
EXACTLY FOLLOWED THESE TUTORIALS AND HAVE ACHIEVED 0 RESULTS:
for bootstrap sass
https://github.com/twbs/bootstrap-sass
for bootstrap https://github.com/twbs/bootstrap
tried using bootstrap CDN
https://www.bootstrapcdn.com/
I have been stuck on this for weeks, tried solving it on my own, followed many blog posts and StackOverflow answers and tried everything.
Is it a problem with rails 5.2 version? or my operating system windows 10
is there a gem missing in my gem file?
EDIT: I can run bundle install successfully, adding CDN in my head tag in application.html.erb does not solve my problem
The problem I am facing is that I cant use bootstrap no matter what method I try
GEM FILE :
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.2.6'
gem 'rails', '~> 5.2.0'
gem 'sqlite3'
gem 'puma', '~> 3.11'
gem 'coffee-script-source', '1.8.0'
gem 'bootstrap-sass', '~> 3.3.7'
gem 'sass-rails', '~> 5.0'
gem 'jquery-rails'
gem 'uglifier', '>= 1.3.0'
gem 'duktape'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false
Maybe try this one:
1) Gemfile
# Add these gems. Rails is not including jQuery by default.
# You need to include it to use all bootstrap options.
gem 'bootstrap'
gem 'jquery-rails'
2) app/assets/javascripts/application.js
jquery3, popper, and bootstrap are the ones for bootstrap
//= require jquery3
//= require popper
//= require bootstrap
//= require rails-ujs
//= require turbolinks
//= require_tree .
3) app/assets/stylesheets/application.scss
#import 'bootstrap'; // assuming you changed to SCSS from CSS
4) Run bundle and restart your server
This is a working repo with Rails 5.2 and Bootstrap 4
https://github.com/HoracioChavez/bootstrap-sample
Tested on macOS
You can try this example. It works for me in my project.
In your Gemfile:
gem 'bootstrap-sass'
gem 'jquery-rails'
In your app/assets/javascripts/application.js
//= require rails-ujs
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
In your /app/assets/stylesheets/application.scss
*= require_tree .
*= require_self
*/
#import "bootstrap-sprockets";
#import "bootstrap";
After you install all gems and make above configurations you can try to test your bootstrap work with this bootstrap dropdown button. Hope it helps you.
Also, please note, that I used bootstrap 3 and worked on Linux Ubuntu.
for rails v5.2.0.
All you need is to ensure you have the gem 'bootstrap-sass' AND gem 'jquery-rails' in the gem file. Bootstrap requires JQuery. Back in other
rails versions i.e v4.x you would have to include alot of other
gems but not anymore in this version they are the default except the bootstrap-sass and jquery-rails gem.
run bundle install to install the gems
Then change the default manifest file app/assets/stylesheets/application.css
filename to app/assets/application.scss(.sass) because we need to
import (load and execute) said file, css cant do that also because the line we intend to include is sass syntax not css syntax.
include #import"bootstrap" in the stylesheet manifest file (application.scss) and prepend //= require jquery in application.js. This affects affects the app/views/layouts/application.html.erb the standard place for all your layout used by all templates in the controller. In older versions here you would have to require other extensions eg. turbolink in order for bootstrap to work effectively and efficiently but no in this version.
Your done. All your web pages are now bootstrap integrated.
I'm unable to use Bootstrap with a Rails app, although it was working for a short while at least.
I've downloaded the precompiled bootstrap files and copied them into the app folder. The gems I'm using are these:
gem 'bootstrap_form'
gem 'bootstrap', '~> 4.0.0.alpha6'
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
gem 'sass-rails', '~> 5.0'
and the version of Rails is 5.1.2. I'm not sure if these gems are compatible with each other, but I have tried removing and updating them, but nothing has worked so far.
In my application.scss file I have
*= require_tree .
*= require_self
*= require rails_bootstrap_forms
*/
#import "bootstrap-sprockets";
#import "bootstrap";
and in my application.js file I have
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
When I try to open the app in local host the error reads- Sass::SyntaxError in Welcome#index.... File to import not found or unreadable: bootstrap-sprockets.
This seems to be a problem with importing the bootstrap files but I'm not quite sure why. Would be most grateful for any suggestions :-)
Rename the file application.scss to application.css.scss
In this way it will work for both css and scss
In Gemfile:-
gem 'bootstrap-sass', '~> 3.3.6'
And remove the gem gem 'bootstrap', '~> 4.0.0.alpha6'
You can use one gem out of the two.
Then precompile the assests as bundle exec rake assets:precompile
I am watching the old One Month Ruby on Rails lectures without being enrolled in the course and encountered this problem. I have searched through about 20 stackoverflow and github tutorials and can't find the problem, any help is greatly appreciated. (This is my first time posting here so if I am doing something wrong or need to include more information let me know).
Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.6'
gem 'jquery-rails'
# Use sqlite3 as the database for Active Record
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
group :assets do
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
end
Styles.css.scss :
#import "bootstrap";
application.js :
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree .
According to the Question its clearly stated that you need to restart your server whenever a gem is installed or updated, if you upgrade ruby, or if you change some logic that runs during boot time (like config/boot.rb or config/database.yml). Otherwise it's generally ok not to, even if you edit/add models/controllers.
Remove group "assets" from Gemfile. It is obsolete in Rails 4.
Rails 4.0 removed the assets group from Gemfile. You'd need to remove
that line from your Gemfile when upgrading.
See Ruby on Rails Guides
you use gem bootstrap-sass than in your application.js use
//= require bootstrap-sprockets
and in your application.css use
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
#import "bootstrap-sprockets";
#import "bootstrap";
No matter what I do, I always get the error
/home/xyz/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bootstrap-sass-3.3.7/lib/bootstrap-sass/engine.rb:11:in `block in <class:Engine>': uninitialized constant Sprockets::Rails::VERSION (NameError)
when restarting the rails server after installing the bundle. I've tried to change version numbers, delete the .lock file and so on, but nothing is working. I'm using Rails 4.2.6.
Here's my Gemfile:
source 'https://rubygems.org'
ruby "2.3.1"
gem 'rails_12factor'
gem 'rails', '4.2.6'
gem 'sprockets-rails'
gem 'pg', '~> 0.15'
gem 'simple_form'
gem 'clockpicker-rails'
gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.37'
gem "font-awesome-rails"
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '~> 4.0.0'
gem 'bootflat-rails' # flat UI skin for bootstrap
application.css.scss:
#import 'bootstrap-sprockets';
#import 'bootstrap';
#import 'bootflat';
#import 'font-awesome';
#import 'bootstrap/clockpicker';
#import 'bootstrap-datetimepicker';
application.js:
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require icheck.min
//= require bootstrap/clockpicker
//= require moment
//= require bootstrap-datetimepicker
//= require turbolinks
//= require_tree .
I've read many similar questions but none of the answers helped me or caused even more problems. It really should'nt be that hard but I just can't figure out what the problem is.
Run this command:
bundle update sprockets-rails
I have encountered the following error when trying to use rails3-jquery-autocomplete:
Initially, I used the latest version of jquery-rails but read that they removed jquery-ui. I have tried downgrading jquery-rails to gem 'jquery-rails', '~> 2.3.0' as recommended in this answer but it did not work. rails active admin deployment : couldn't find file 'jquery-ui'
I also tried restarting my server as suggeste din this answer but did not work either. Asset Pipeline not finding JS file
I would greatly appreciate an explanation as to how to do this in rails 4 using jQuery mobile without the gem as I have no idea and can't find any recent resources.
couldn't find file 'autocomplete-rails'
application.js
//
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require autocomplete-rails
//= require jquery.mobile
//= require turbolinks
//= require_tree .
gemfile
gem 'rails', '4.0.0'
gem 'jquery-rails'
gem 'jquery_mobile_rails'
gem 'jquery-ui-rails'
gem 'rails3-jquery-autocomplete'
You can use this fork https://github.com/francisd/rails3-jquery-autocomplete
In your Gemfile change
gem 'rails3-jquery-autocomplete'
to
gem 'rails3-jquery-autocomplete', git: 'https://github.com/francisd/rails3-jquery-autocomplete'