bower and ruby on rails

12
DOGS AND CATS LIVING TOGETHER Mass Hysteria!

Upload: ivan-storck

Post on 19-Jan-2015

340 views

Category:

Technology


4 download

DESCRIPTION

Front-end dependency management in Rails is a bit of a mess. Engines, other Gems, Downloading files manually... Bower to the rescue!

TRANSCRIPT

Page 1: Bower and Ruby on Rails

DOGS AND CATSLIVING TOGETHER

Mass Hysteria!

Page 2: Bower and Ruby on Rails

RAILS ENGINESMANUAL DOWNLOADS

Page 3: Bower and Ruby on Rails

BOWER + RAILS

Page 4: Bower and Ruby on Rails

RAILS NEW BOWERAILS$ rails new bowerails create create README.rdoc create Rakefile create config.ru create .gitignore create Gemfile create app ...Using rails (4.0.2)Using rdoc (3.12.2)Using sass (3.2.12)Using sass-rails (4.0.1)Using sqlite3 (1.3.8)Your bundle is complete!Use ̀bundle show [gemname]̀ to see where a bundled gem is installed.

Page 5: Bower and Ruby on Rails

ADD BOWER­RAILS TO GEMFILEsource 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'gem 'rails', '4.0.2'

# Use bower for front end assetsgem 'bower-rails'

and then?bundle

Page 6: Bower and Ruby on Rails

GENERATErails g bower_rails:initialize create bower.json

results in a bower.json file containing:{ "lib": { "name": "bower-rails generated lib assets", "dependencies": { } }, "vendor": { "name": "bower-rails generated vendor assets", "dependencies": { } }}

Page 7: Bower and Ruby on Rails

CONFIGUREconfig/application.rb

module Bowerails class Application < Rails::Application

# Configure Bower config.assets.paths << Rails.root.join('vendor', 'assets', 'bower_components') endend

Page 8: Bower and Ruby on Rails

CONFIGURE, STEP 2app/assets/stylesheets/application.css

*= require bootstrap

app/assets/javascripts/application.js//= require bootstrap

Page 9: Bower and Ruby on Rails

Bowerfileasset "bootstrap"

and then...

Installrake bower:install

Page 10: Bower and Ruby on Rails

BIZOWZER!rake bower:update

keeps your front-end compenents up-to-date!

Page 11: Bower and Ruby on Rails

EXAMPLE APP AND SLIDESClick here: Example Bower Rails App