Upgrade twitter bootstrap using twitter-bootstrap-rails gem - ruby-on-rails-3

Im using the twitter-bootstrap-rails gem in my application.
I discovered that this gem uses the 2.3 twitter bootstrap version cause i have to use
class="span6"
not
class="col-md6"
when creating a grid.
How can I upgrade to bootstrap 3?

https://github.com/seyhunak/twitter-bootstrap-rails#using-stylesheets-with-less shows you howto include your LESS file, include the LESS files of Twitter's Bootstrap 3 here?
You have to require Bootstrap LESS (bootstrap_and_overrides.css.less)
in your application.css
/* *= require bootstrap_and_overrides */
/* Your stylesheets goes here... */ To use individual components from
bootstrap, your bootstrap_and_overrides.less could look like this:

Related

Use Haml files in Redmine plugin

I am creating a Redmine plugin and would like to use Haml for the view templates. There is an existing plugin which has Haml views (ekanban) and it does not contain any special code to get Haml working other then having you add require 'haml' to your main application's Gemfile.
So here is what happens -- the templating system loads the .html.haml file correctly but renders the HAML markup (like it was rendering ERB).
I've tried to insert the require 'haml' at various intervals to no avail. I've even tried manually trying to activate Haml.init_rails(...) as suggested in this SO question. I've tried inserting that in a few places, tried it in a Rails.configuration.to_prepare block in the plugins' init.rb file. I've tried telling the Gemfile to not require 'haml' and attempting to do it during plugin load to no avail. What gives?
The view template had Textile in it and I did not notice because the markup for <h2> is similar (h2. vs. %h2). Including gem 'haml_rails' in the plugin's Gemfile is sufficient with no extra code.
Read carefully Installation instruction for this gem :)
Add "gem 'haml'" to your #{RAILS_ROOT}/Gemfile
I can't agree with this strategy: plugin can't change Redmine core! Any Redmine plugin can have own gems (defined in own Gemfile) - so I think you can create Gemfile in your plugin, run bundle install from the Redmine root and I believe you will manage to use Haml

Twitter bootstrap: do I need both bootstrap-sass and twitter-bootstrap-rails gems?

I have the following entries my (Rails 3.2.13) Gemfile:
gem 'twitter-bootstrap-rails'
gem 'bootstrap-sass'
and in app/assets/javascripts/application.js:
//= require twitter/bootstrap
and at the top of app/assets/stylesheets/custom.css.scss:
#import 'bootstrap'
Is this "correct"? Do I need both 'twitter-bootstrap-rails' and 'bootstrap-sass' (or maybe 'bootstrap-sass-rails'), or are they redundant and possibly conflicting? Do the 'bootstrap-sass' gems include the javascript for the framework, or only the CSS?
No you do not need both.
Just simply put this in your gemfile:
gem 'sass-rails'
gem 'bootstrap-sass'
This in application.css.scss:
#import 'bootstrap';
#import 'bootstrap-responsive';
This in application.js
//= require bootstrap
If you're still having problems you may need to look at the ordering of things in your manifest files..
If you want to use SASS you should use boostrap-sass or bootstrap-sass-rails. Twitter-bootstrap-rails uses LESS source. If you were to include both there would probably be conflicts. All of them include javascript for bootstrap already and integrate into the asset pipeline.
I personally use LESS version as it is what bootstrap is originally written in. (might get faster releases when bootstrap updates)
It's generally good to check the gems out on github to evaluate your exact needs and which version of Rails they support.

How to use SASS, HAML, and CoffeeScript in Rails 3.2.x Engine?

Currently, I have a Rails 3.2.9 Engine which is using sass-rails. When I generate a controller with a couple actions, the assets are also generated (i.e., javascript and CSS). However, both the Javascript and SASS are *.js and *.css files. They're not CoffeeScript (*.js.coffee) or SASS (*.css.sass). Any ideas how to get this work?
Here's a different solution which will use the coffee-rails and sass-rails gems by default - also fixes haml-rails.
I added this to the top of my engine.rb file:
require 'rails'
require 'coffee-rails'
require 'sass/rails'
require 'haml-rails'
What I did was inspect the source code of these files to see how they work in a normal Rails application. For example, in haml-rails I looked at lib/haml-rails.rb and saw the following:
require 'haml'
require 'rails'
module Haml
module Rails
class Railtie < ::Rails::Railtie
if ::Rails.version.to_f >= 3.1
config.app_generators.template_engine :haml
else
config.generators.template_engine :haml
end
...
Similar files exist for sass-rails (lib/sass/rails/railtie.rb) and coffee-rails (lib/coffee/rails/engine.rb).
Just append --stylesheet_engine=sass --javascript_engine=coffee to your generator command (I'm assuming rails g controller).

Using Google CDN with the sprockets assets compiler

This seems quite trivial but couldnt find it in the forums or rails asset pipeline guides.
In short
How can I inform sprockets to skip the asset pipeline for the jquery ui css of the 'jquery-rails' gem.
In long:
I am trying to use 'jquery-rails' gems with the Google jquery CDN's.
Hence in the I am just including the jquery_ujs and adding the jquery related scripts in the application layout:
application.js.erb:
//= require bootstrap-twipsy.js
//= require jquery-glowing
//= require jquery_ujs
application.html.erb:
= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jqueryui.min.js"
For the css', I am not including the jquery-ui css in the application.css and adding it in the layouts file too.
application.css.scss.erb:
*= require_directory .
*= require active_scaffold
*= require_self
In production environment, the compiled css file includes the jquery-css code too, since its in the assets pipeline of the 'jquery-rails' gem.
So how can I inform sprockets to skip the asset pipeline for the jquery ui css of the 'jquery-rails' gem.
If this is not possible in rails, what is the best way to handle this sittuation.
I thought about removing the jquery-rails gem, and adding the jquery_ujs javascript manually to the system, but then I have to deal with the installation of new releases rather than executing a simple 'bundle update'
Thanks in advance,
The problem is in the active_scaffold gem, right here if you want the code reference. It includes the jquery-ui CSS.
To remove this you'll need to replicate the entire active scaffold css code in your app/assets/stylsheets folder (as my_active_scaffold), removing the link to jquery-ui. I am assuming that the ActiveScaffold erb at the end of the file will still run in this context.
Then just include it:
*= require my_active_scaffold

Rails 3.1 + ActiveAdmin GEM css/stylesheet conflict?

I must be missing something really simple, but I could not find anyone else with the problem.
Basically, Rails 3.1 merges all the .css files into application.css. After I installed ActiveAdmin, ActiveAdmin's CSS are also merged into application.css, causes conflict and overrides my stylesheet.
What am I missing here?
I removed *= require_tree . from application.css and added each other css individually. Not sure whether this is the best way, but it works.
I solved it by adding the generated active_admin css and js in the vendor directory..
vendor/assets/stylesheets/active_admin.css.scss
vendor/assets/active_admin.js