Using twitter bootstrap 3 with rails using bootstrap-sass gem - css

Right now my bootstrap css version is v2.3.2 with following gem
gem 'bootstrap-sass', '~> 2.3.2.1'
I tried to upgrade it by using following configuration
gem 'bootstrap-sass', git: 'https://github.com/thomas-mcdonald/bootstrap-sass.git', branch: '3'
But after restarting the server and everything the version remained the same
So I tried bundle exec rake convert, maybe it could fix the problem
But it kept throwing
Don't know how to build task 'convert'
So does anyone have any idea how to implement bootstrap v3 into my rails project ??

I had to run this command
rake tmp:clear
In order to clear the cache from bootstrap v2 files

As per the instructions at rubygems.org, you have to run this command to get the new gem. I assume this is because it is using release candidates.
$ gem install bootstrap-sass --pre
I don't know how you would do this in the Gemfile.

The bootstrap-sass github page is not so clear.
You don't need to run the convert task unless you're working or developing the gem itself.
You just need to follow the bootstrap-sass rails install guide

Related

What is the proper way to upgrade Bootstrap 4 for Rails?

I tried to upgrade from Bootstrap 4 Alpha 6 to 4.0.0 final version for my Rails 5 project, I'm sure the v4.0.0 gem has been installed (I also uninstalled the alpha version gem), but when I run my project (dev mode), I found the generated Bootstrap CSS files are still based on the Alpha version.
gem 'bootstrap', '~> 4.0.0'
Other than uninstalling the old gem and install the new bootstrap gem, do I need to do anything else for the upgrade? Download the physical v4.0.0 files and replace the old files in my project?
You can have look at this article:
How to update a single gem conservatively
Option 1
This will work if all dependencies for the update are already satisfied.
Find out the version you want to update to
Change it directly in Gemfile.lock
Run bundle install and see if that worked
Option 2
This will work if the gem has no shared dependencies with other gems.
Find out the version you want to update to.
Add that version explicitly to the Gemfile with , '=1.2.3'
Run bundle install
Remove the explicit version number again
Run bundle install once more
Option 3
This should always work.
Run bundle update GEMNAME
Run git diff Gemfile.lock and notice all the updates you didn't want
Revert the unwanted changes to Gemfile.lock you don't want (manually or by staging changed lines one-by-one), leaving only the desired updates.
Run bundle install and see if that worked
Option 4
There are persistent rumors that you can update a single gem by calling bundle update --source GEMNAME. However no one seems to know how and why this works, it's not a documented feature of Bundler. It might be an unintended side effect of something else.
I believe this command will try to update GEMNAME and GEMNAME only. If this leads to unmatched dependencies to other locked gems, it will fail.
If you use this option, be sure to git diff your Gemfile.lock to see if the changes are what you expected.
Option 5
Bundler >= 1.14 has a --conservative flag. Using the conservative flag allows bundle update GEM to update the version of GEM, but prevents Bundler from updating the versions of any of the gems that GEM depends on.
Credits To Author: Henning Koch
Try to keep Ruby dependencies in your Gemfile and JS/CSS ones elsewhere. Node+Yarn is a good way to do that.
If not already there
brew install yarn
Then in config/initializers/assets.rb
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Now you can do this in your console:
yarn add bootstrap
It should have create a node-modules directory if not already there.
Then just add bootstrap to your JS/SCSS files
JS
//= require bootstrap/js/src/index
CSS
#import "bootstrap/scss/bootstrap";

Upgrading bootstrap version - twitter-bootstrap-rails

I am using bootstrap gem in my project.
gem 'twitter-bootstrap-rails'
The bootstrap version that i have now is
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
I need to upgrade to latest bootstrap version.
It seems like the bootstrap version is not updated in the gem (https://github.com/seyhunak/twitter-bootstrap-rails/blob/master/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb).
How can i upgrade the version in my application?
There are several options:
You can fork twitter-bootstrap-rails gem, update BS to version 4 and edit your Gemfile:
gem 'twitter-bootstrap-rails', git: 'link_to_your_fork'
You can migrate to bootstrap-rubygem gem instead which uses BS4
You can download latest version of BS from official site and manually put .js and .css files to ./vendor/assets/ directory. Look at these SO answers for reference: first and second
For options 2 and 3 make sure you dont use helper methods in your code which twitter-bootstrap-rails gem provides

Rails 5: Could not load 'active_record/connection_adapters/sqlite3_adapter'

I'm using Ruby 2.3.1 on Windows 7. Based on http://guides.rubyonrails.org/getting_started.html I tried to create a Rails 5 app afresh, but without success due to gem sqlite3-1.3.11.
The first error after "rails start" was "cannot load such file -- sqlite3/sqlite3_native (LoadError)". The problem was solved by Error when starting the Rails server on Windows . That's okay.
But it was impossible for me to fix the second error (LoadError in browser):
"Could not load 'active_record/connection_adapters/sqlite3_adapter'."
Who can help?
This problem may be sqlite is not correclty installed
Firstly check your gem file for line gem 'sqlite3' if not add and run bundle install if problem still persists follow the steps below:
Go to rubyinstaller.org
Download Devkit and setup
Remove Sqlite3 Gem by running gem uninstall sqlite3
Reinstall sqlite3 by running gem install sqlite3
Include gem 'sqlite3' in Gemfile
If still doesn't work your problem is due to version of ruby you are using. Please downgrade your ruby version or Install linux in your machine. I had also used ruby in windows and this actually caused headache and I switched it into linux.

Sass --compass --watch Error: Cannot load compass

I am working with sass and compass and trying to use the new sourcemap feature as Chrome 27 requires the new method of sourcemap to show the actual sass files and line numbers in the chrome console panel.
I am able to run the following sass command sass --sourcemap --watch style.scss:style.css
however if I append the --compass argument like the following sass --compass --sourcemap --watch style.scss:style.css
I get the following error in the windows cmd panel: "ERROR: Cannot load compass".
I have tried following some of methods that apparently worked for some people on the github issue page https://github.com/chriseppstein/compass/issues/1108
The methods I have tried are using the sass 3.3.0.alpha.177 with compass 0.12.2 (this producers an error every time I try and execute the compass gem which is almost identical to this issue Why does "compass watch" say it cannot load sass/script/node (LoadError)?)
Currently my setup is the following:
sass 3.3.0.alpha.177
compass 0.13.alpha.4
Windows 7
Is there a way that I can use Sass with compass and at the same time generate the sourcemaps which are needed for css debugging?
I found that I had two versions of Sass installed (3.4.25 and 3.5.5). I was getting the error when using grunt which was using the latest version 3.5.5. I resolved the problem by uninstalling 3.5.5.
gem uninstall sass
→
Select gem to uninstall:
1. sass-3.4.25
2. sass-3.5.5
3. All versions
Works with Sass 3.3.0.alpha.149 and compass 0.12.2 on windows 7
The versions mentioned by #lollerskates666 work, but I had to specifically remove sass version 3.3.4 which came down when I installed compass.
If anyone else if having this difficulty, I had to run the following rules to get it working:
gem install compass --version 0.12.2
This installs compass and also Sass 3.3.4 (Maptastic Maple). These two versions, combined with --sourcemap don't seem to play nicely, so you'll need to install an older version of Sass:
gem install sass --pre --version 3.3.0.alpha.149
Although you've now installed it, if you run:
sass --v
Ruby will still be using Sass version 3.3.4, so you'll need to uninstall this version:
gem uninstall sass
**Select number assigned to version 3.3.4**
Now, if you run:
sass --v
You should see:
Sass 3.3.0.alpha.149 (Bleeding Edge)
Sass should now work with the compass lib and also produce sourcemaps, which Chrome can read :)
I run this command to watch my scss files:
sass --watch --sourcemap --compass --style compressed scss:css
Hope this helps!!
** I'm running this on a Mac, but the same versions work fine :)
Had this problem as well. gem 'sass', '~> 3.2.19' was working on a previously created application. I resorted to using that instead of gem 'sass', '~> 3.4.16 which was automatically generated at creation time for a 3.2.22 app and which generated this problem.
So there does appear to be an issue with the version.

Sqlite-3 error while running ROR application

When i try to run Ruby on Rails application.... i facing the following error
symbol lookup error: /home/user/.rvm/gems/ruby-1.9.2-preview3/gems/sqlite3-ruby-1.3.0/lib/sqlite3/sqlite3_native.so: undefined symbol: sqlite3_initialize
I don't know whats the error exactly. can any one please help me out this......
I had the same issue this morning after upgrading sqlite3-ruby to 1.3.0. A quick fix is to uninstall 1.3.0 and ensure 1.2.5 is installed:
gem uninstall sqlite3-ruby --version 1.3.0
gem install sqlite3-ruby --version 1.2.5
The better option is to set your gem config to ignore 1.3.0. For Rails 2.x, in config/environment.rb:
config.gem 'sqlite3-ruby', :lib => 'sqlite3', :version => '!= 1.3.0'
or if you want it play it really safe, explicitly pull in 1.2.5:
config.gem 'sqlite3-ruby', :lib => 'sqlite3', :version => '1.2.5'
If you lock your gemfile to sqlite3-ruby you will have problems starting your application on recent Rails versions since Rails wants to have the gem named "sqlite3". The real solution to this problem is to ensure that the .bundle file that the gem creates indeed links to the right sqlite3 libraries.
By default, sqlite3 gem will link to a nonexisting library in your /usr/lib. This is NOT right. What you need to do is set the compliation options straight for your system and reinstall the sqlite3 gem, and you can easily do this using
$bundle config
Their manpage specifies what it does, but this is the command that I needed to do (I have a roll-your-own SQLite install from their site, not via brew or macports).
$bundle config build.sqlite3 --with-sqlite3-include=/usr/local/include --with-sqlite3-lib=/usr/local/lib
This will always feed the right options to the gem when you try to "bundle install" it and your gem will build properly.
Note that this problem is kinda sneaky in that it will not occur on Ruby 1.9 - apparently rbconfig there has been updated and does better library lookup. But when you are going for 1.8 compatibility - use this bundle configuration and you will be all set.
I'm had the same issue on my Dreamhost server:
> bundle exec rails c
ruby: symbol lookup error: /home/user/settings/installs/rubygems/gems/gems/sqlite3-ruby-1.3.0/lib/sqlite3/sqlite3_native.so: undefined symbol: sqlite3_initialize
I downloaded and installed SQLite3 manually in my home directory, and added LD_LIBRARY_PATH to my .bashrc. This fixed the Rails console issue.
However, I still haven't gotten the app to launch in passenger yet, I'm still working on it.
Ruby Enterprise Edition installs the sqlite3 gem automatically, and 1.3.0 seems to be the problem.
If your Rails app doesn't need sqlite3, try uninstalling the gem and restarting your app.
sudo gem uninstall sqlite3

Resources