Twitter bootstrap and rails - ruby-on-rails

Im trying to put the bootstrap source files in my rails project but I am not seeing an "assets" folder in my app folder. Are the Image, Javascript, and CSS folders in "public" the same thing? If not then where do I put the source files? I am using ruby version 1.9.2-p290, rails version 3.0.19, and bootstrap version 2.3.2. Not sure if that makes a difference or not.

Why don't you just use a bootstrap gem like bootstrap-sass instead?

Look at this project: twitter-bootstrap-rails
It is an easy way to set up bootstrap in your Ruby on Rails project.

Related

Do I have access to the raw sass files using the bootstrap-rubygem gem?

I added the bootstrap-rubygem gem to my rails 5 application.
In my application.scss file I added:
#import "bootstrap";
Do I have access to the scss files that bootstrap uses? It is possible to install them so I can manually update them?
You have access to the scss files and you can change the variables, but the documentation is based on the latest version of Bootstrap v4.0.0-beta.3.
The bootstrap-rubygem uses different versions of bootstrap from the latest v4.0.0.beta3 to previous oldest alpha versions.
As explained in the documentation this is the files structure of the bootstrap project,
The scss files and partials from the twitter-bootstrap github repository are included in your bootstrap-rubygem assets/stylesheets/bootstrap folder so they will probably be available to you inside your rbenv or rvm folder.
I discourage you in going into the bootstrap source to edit those files, it is discouraged in the docs itself, instead use scss variables, functions and mixins as described in their documentation
https://getbootstrap.com/docs/4.0/getting-started/theming/#variable-defaults
I notice now that v4.0.0beta3 is available with the bootstrap-rubygem, as in my last probject I installed it with yarn and the files are included in /node-modules, but I don't really believe it is an advantage if the gem does not have bugs.

Use compass in gem for rails application

I'm trying to create a gem which represents a JS and CSS library and can be included in rails projects (currently using 3.2). All the style sheets are written in SASS and depend on the compass library.
I tried adding compass-rails to the Gemfile of the "external" gem and including it in the gems SASS files using
#import "compass"
However, back in the rails application (which has a dependency to this gem), this results in an error message:
File to import not found or unreadable: compass.
Am I doing something wrong?
Update: It seems to work if I add gem compass-rails to the Gemfile of the rails application. Any change to work around that?
Thanks a lot for your help!
Besides adding compass-rails to the Gemfile of the gem, you also need to require 'compass-rails' somewhere, adding it to lib/your_gem_name.rb inside the gem worked for me.

Uninstalling Twitter Bootstrap from a Rails app

I recently installed Twitter Bootstrap in my Rails app via the following two steps:
rails g bootstrap:install
(this included Twitter Bootstrap to my app's asset pipeline)
rails g bootstrap:layout application fixed
(this generated a layout for me, by default application.html.erb and fixed layout was generated)
Should I do any of the following or all of it to remove Twitter Bootstrap completely from my app?
Delete all the files added by it in APP folder?
javascripts/bootstrap.js.coffee
stylesheets/bootstrap.js.coffee
layout/application.html.erb (edit this file?)
Are there other files that were created that I missed and must also remove?
Try this
rails destroy bootstrap:install
Also, remove the gem from your gemfile
gem "twitter-bootstrap-rails"
If you look at the github repo for this you can see the generators and what exactly they do:
https://github.com/seyhunak/twitter-bootstrap-rails/tree/master/lib/generators/bootstrap
The command
rails g bootstrap:install
Uses the templates here:
https://github.com/seyhunak/twitter-bootstrap-rails/tree/master/lib/generators/bootstrap/install/templates
The layout command uses the templates here:
https://github.com/seyhunak/twitter-bootstrap-rails/tree/master/lib/generators/bootstrap/layout/templates
Also, remove the gem from your gemfile
gem "twitter-bootstrap-rails"

Using Sass in rails 3.0.1

i am trying to use sass in a rails 3.0.1 project that i am working on. I install the gem but when i create a scss file and add some style nothing happens. I've been searching for an answer and it seems others have haml installed as well, do I need this?
I think you should add the assets pipeline (Sprockets) in addition to SASS.
Here is a gist that explains the setup for Rails 3.0.x.
https://gist.github.com/911003

Add Blueprint to a Rails 3 project using compass gem

I have a new Rails 3 project. I have installed Compass. I would like to generate the stylesheets in app/stylesheets using the Blueprint framework.
compass init rails /path/to/myrailsproject --using blueprint/semantic
Accept the defaults when prompted; your Sass files will be put in app/stylesheets and the compiled css will be put in public/stylesheets/compiled.

Resources