Bootstrap SASS Install - ruby-on-rails

I am keen to use the new Bootstrap SASS however I have noticed that a precision value has to be added to continue. I am aware of this bug and how it benefits the project.
However I am unsure how to build this into my project, the Bootstrap Docs are pretty lacking here..
::Sass::Script::Number.precision = [10, ::Sass::Script::Number.precision].max
This was the code given above and link here - https://github.com/twbs/bootstrap-sass
I would note that I have already installed downloaded the gem and installed it using bower. Just need to get this code a place to call home!

Try putting the one-liner in application.rb
https://github.com/twbs/bootstrap-sass/issues/409

Related

What is therubyracer or libv8 for in a rails application?

I was working on a project and was having issues with therubyracer and libv8 often, so i decided to remove them. It seemed to be the only thing that used them as a dependency was less-rails which I wanted to remove anyways.
My main question is what are they for and do I need them in the average application and if so why?
There are a few things for which a Rails app might use a Javascript Runtime:
1) The Rails Asset Pipeline requires a Javascript Runtime in order to perform Javascript compression.
2) Certain Rails ActionView Helpers like javascript_include_tag require a Javascript Runtime in order to execute Javascript functions.
Not every Rails application use those features, hence the reason that therubyracer gem is initially commented out in your Gemfile; Furthermore note that you could alternatively use NodeJS as your Javascript runtime.
For details, see:
http://guides.rubyonrails.org/asset_pipeline.html#javascript-compression
http://www.rubydoc.info/docs/rails/ActionView/Helpers/JavaScriptHelper
http://www.rubydoc.info/docs/rails/ActionView%2FHelpers%2FAssetTagHelper%3Ajavascript_include_tag
Proper "Rails" way to perform javascript on specific pages
rubyracer provides following features:
1. We can write your ruby codes inside js codes.
2. We can invoke the js functions from ruby codes.
3. Manipulation of javscript objects & the passing them to javascript functions.
Those are the few basic benefits of using rubyracer gem.
Please read complete details here

what's the point of having a jquery-rails

So I installed Ruby on Rails(first time) and got down to starting a new project and a server. So as expected there was an error on running the Rails server command. Some gems needed to be installed, apparently. The bundle install command didn't work for some wierd ssl issue. So I decided to do it all
manually.
What strikes me as odd is that there's a gem for jQuery: jquery-rails. I don't understand the point of this, really. Why not simply download the jquery file and put it in public.
What's the point of having a gem here.
Is it simply convinience or is there another important reason behind it?
Jquery-rails does 2 things. First of all it bundles the appropriate version of jquery. I consider this only a convenience for jquery itself. For something like jquery-ui, jquery-ui-rails does a lot more: since jquery-ui is modular, that gem will serve to clients only the bits of jquery-ui you are using.
The other thing in jquery-rails is jquery-ujs. This is javascript that makes things such as passing the :remote => true option to form_for work. It used to be that rails itself contained a version of this for prototype, but with rails 3 this was extracted from rails to make it easier to use other javascript libraries than rails' previous default of prototype
I think this is a good idea, because it makes JQuery available as a versioned dependency.
If you need to update JQuery, you just have to change the version at one place in your app, and every page that needs it will use the new version.
And based on its homepage, there's also a test helper that you can use in your tests.

Updating to Rails 3.2.2: How to properly move my plugin from the '/vendor' to '/lib' directory?

I am upgrading Ruby on Rails from 3.1 to 3.2.2 and I would like to know what I should make and at what I should be care in order to properly move my vendor plugin (note: it is not a gem and at this time I am not planning to make that a gem) from the directory /vendor to /lib as well as wrote in the official documentation:
Rails 3.2 deprecates vendor/plugins and Rails 4.0 will remove them completely. You can start replacing these plugins by extracting them as gems and adding them in your Gemfile. If you choose not to make them gems, you can move them into, say, lib/my_plugin/* and add an appropriate initializer in config/initializers/my_plugin.rb.
I refer mostly to the "an appropriate initializer in config/initializers/my_plugin.rb": What code should I put in that file?
More: Do you have some advice or alert on making the above process?
The initializer should contain the appropriate requires and other startup related tasks that are necessary for your plugin to work correctly. It's difficult to help you without real code examples from your app but this link should help you get started.
http://code.coneybeare.net/how-to-convert-simple-rails-23-style-plugins
The example in the link requires the plugin (now in the lib directory) and adds a module to ActiveRecord::Base.

How to use Twitter bootstrap with rails 3.0

How am I supposed to use bootstap with rails 3.0 rather than >= 3.1 ? is there any plugin which supports rails 3.0 ?
I think all of the bootstrap gems require Rails 3.1 or greater. I recently had bootstrap on a 3.0.10 Rails app using the Less.js file that you download from their site: http://lesscss.org/. This is the simplest most basic way to use Twitter-Bootstrap; the file compiles all of your "my_file.less" files into css on the client side.
However, if you want to modify the variables (which is the real power of using this framework) than you need to compile it. You can take a look at this Less compiler: http://wearekiss.com/simpless. I've never tried that, but I hear good things about it and it works on Mac, Linux, or PC.
Probably the easiest thing to do - if you want to compile the code on server side - would be to upgrade your project to Rails 3.1.1 and just use one of the Twitter Bootstrap gems. This is actually exactly what I ended up doing. I was able to update my app to 3.1.1 and I used the Boostrap-Sass gem (just because I slightly prefer Sass).
If you decide to upgrade, follow this RailsCast: http://railscasts.com/episodes/282-upgrading-to-rails-3-1
It helped me a lot.
Ryan Bates also offers a video on how to incorporate Twitter Bootstrap into a Rails app: http://railscasts.com/episodes/328-twitter-bootstrap-basics.
Here's a link to the Sass version of Bootstrap that I am currently using: https://github.com/thomas-mcdonald/bootstrap-sass
Many solutions : you can upgrade to rails 3.1+, might be the better (not the easier, depending on you app) way. You can include the static files yourself if you don't intend to change anything that is handled at the less level. You can do it even if you intend to, but you'll have to recompile the files yourself (or find a way to automate it). Finally, there might be a gem out there that is compatible with rails pre-asset-pipeline, or an old version of a gem. You'll have to look for yourself if you absolutely want a gem.

How to override Zurb Foundation css properties using rails 3.1?

Hi there im working on a new rails app and i just started to use Foundation.
I did the installation using
rails g foundation:install
Everything is working as espected (i mean by that i can see the css in my source code, and also the visual effect of it ;p)
I just dont understand how to override the defaults proprieties of Zurb Foundation...
I saw online that im supposed to edit some foundation.css or app.css but here doesnt seems to be any file like that in my Application folder....
I did the installation by editing the gemfile then a bundle install.
cheers
and yes it works if you do your overrides on the app/assets/stylesheets/application.css
But it's better if you do it in the app/assets/stylesheets/foundation_and_overrides.scss,
also at the top of the file, there's a bunch of lines commented, with those lines you can also modify some attributes!
Option 1: Since you installed it through bundler (assuming you used something like gem 'zurb-foundation'), you won't have any files that you can edit directly. You can override and style as usual by editing app/assets/stylesheets/application.css or adding new files within the directory. I'd recommend this over modifying Zurb so you can continue receiving the benefits of being able to upgrade to newer versions of Zurb in the future without dealing with a mess.
Option 2: If you feel that you need more control over the customization and you aren't worried about the above pitfalls, you can clone/download foundation-rails and copy the files in vendor/assets to your own Rails directory of the same name. Remove zurb-foundation from your Gemfile, rebundle, and you should be able to modify the assets directly in your own project.
Option 3: Check out foundation-sass and give Compass a try. I haven't looked into it much but you should have some amount of customization through mixins.

Resources