• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Rails 3.1
 

Rails 3.1

on

  • 1,366 views

Another new version of Rails. Delightful. And terrifying. What's changed this time? Fear Not!...

Another new version of Rails. Delightful. And terrifying. What's changed this time? Fear Not!

We'll be reviewing the changes and additions to Rails 3.1, giving you a walk-through of what it all means (asset pipeline, what?), in the context of a brand new app, and an older app that will need to be upgraded.

Statistics

Views

Total Views
1,366
Views on SlideShare
1,208
Embed Views
158

Actions

Likes
0
Downloads
12
Comments
0

4 Embeds 158

http://www.wndx.com 127
https://lori-olson-cwsl.squarespace.com 27
http://www.linkedin.com 3
https://twimg0-a.akamaihd.net 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • So, out with the old, and in with the new. Prototype was the default Javascript library in Rails since the very beginning. There have been rumblings for several (intermediate) versions, but they finally pulled the trigger and did it.\n
  • However, if you just HAVE to use Prototype, it is just a simple -j option away. The choice of Javascript libs is now tucked away into a couple of gems\n\n\n
  • gem 'jquery-rails' or gem 'prototype-rails' will show up in your Gemfile\nAnd prototype or jquery js will be included via your application javascript manifest file\n- But, I get ahead of myself\n\n
  • Almost 10x more popular than Prototype\n\nPopularity == ecosystem\n\nVersioning... rails dictates which jQuery version now, which is better\n
  • Infographic\nfile:///Volumes/loriolson/Confoo/Javascript%20Frameworks%20and%20jQuery%20(Infographic)%20%7C%20Web%20Resources%20%7C%20WebAppers.webarchive\n
  • \n
  • But it’s important to note that CoffeeScript, while defined as a dependency by default in Rails 3.1, is not a requirement. You can just stick with pure Javascript (and jQuery) and call it done.\n\nNow, I consider myself just a dabbler in CoffeeScript, so I won’t spend a lot of time on it.\n\n
  • Thomas Fuchs, author of the Scriptaculous framework, co-author of the JavaScript Performance Rocks! ebook had this to say about CoffeeScript\n
  • However, if you really want to learn it, and I suggest you do, there are some great resources out there. \n
  • Syntactically Awesome Stylesheets\n
  • \n
  • Guess which one is recommended? ;-)\n
  • \n
  • \n
  • It makes CSS and JavaScript first-class code citizens and enables proper organization, including use in plugins and engines\n
  • So, the assets (images, javascripts, & stylesheets) have been tucked under public, all this time.\n\nNow, they are slotted in under the app/assets directory\n
  • So, the assets (images, javascripts, & stylesheets) have been tucked under public, all this time.\n\nNow, they are slotted in under the app/assets directory\n
  • So, the assets (images, javascripts, & stylesheets) have been tucked under public, all this time.\n\nNow, they are slotted in under the app/assets directory\n
  • So, the assets (images, javascripts, & stylesheets) have been tucked under public, all this time.\n\nNow, they are slotted in under the app/assets directory\n
  • \n
  • \n
  • generate something to run on heroku to demo diff\n
  • \n
  • Average load time\nNumber of resource requests\nCDN\n\n
  • Active Record has an Identity Map in Rails 3.1. An identity map keeps previously instantiated records and returns the object associated with the record if accessed again. The identity map is created on a per-request basis and is flushed at request completion.\nRails 3.1 comes with the identity map turned off by default. There are issues...\n
  • \n
  • \n
  • \n
  • Didn’t used to be able to nest these\n\nWord of warning. You may, or may not run into problems on non-default databases. And I can practically guarantee the you will have problems if you used this in conjunction with a legacy database with composite primary keys.\n
  • change\n
  • Instead of up and down. This works for straight-forward migrations, but if you are doing something special, you will probably still want up & down.\n
  • HTTP Streaming is another change that is new in Rails 3.1. This lets the browser download your stylesheets and JavaScript files while the server is still generating the response. This requires Ruby 1.9.2, is opt-in and requires support from the web server as well, but the popular combo of nginx and unicorn is ready to take advantage of it.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Rails 3.1 Rails 3.1 Presentation Transcript

  • Rails 3.1 Lori Olson Confoo 2012 Montreal, QC
  • Another new version of Rails. Delightful. And terrifying. Whats changed this time?
  • Summary• jQuery• CoffeeScript• SASS• Asset Pipeline• Miscellaneous cool stuff
  • But...• What about Rails 3.2? • only released a few weeks ago • not nearly as many scary changes
  • jQuery
  • What you HAVE to know• How to go back to Prototype (not recommended • rails new my_app -j prototype
  • Differences• Gemfile gem ‘jquery-rails’• application.js //= require jquery //= require jquery_ujs
  • But... Why jQuery?
  • CoffeeScript
  • What you HAVE to know• Nothing• Absolutely not required• Just remove one line from Gemfile • gem coffee-rails • And you don’t even have to do this
  • Thomas Fuchs on CoffeeScript• May 2011 - "I just like javascript too much to have a use for that, but I understand why other people might like it"• Aug 2011 - There, it happened. Mistakenly typed CoffeeScript in a .js file. So easy to pick up, and so natural.
  • CoffeeScript Resources• Railscasts • CoffeeScript Basics • http://railscasts.com/episodes/267-coffeescript-basics• Peepcode • Meet CoffeeScript • http://peepcode.com/products/coffeescript• Books • Pragmatic Programmers - CoffeeScript • O’Reilly - The Little Book on CoffeeScript
  • SASS
  • What you HAVE to know• Nothing• Absolutely not required• Just remove one line from your Gemfile • gem sass-rails • And you don’t even have to do that
  • Is it SASS or SCSS?• Sass is the older style HAML-like indented syntax• SCSS is the new main syntax, which is a superset of CSS3
  • Why SASS?• Variables• Nesting • DRY up your styles• Mixins • reusable chunks • with arguments!• Selector Inheritance
  • Alternatives to SASS• Less• HSS• Other, technology specific • XCSS (PHP) • CleverCss (Python) • CSS Crush (PHP)
  • Asset Pipeline
  • assets dir
  • assets dir
  • assets dir
  • assets dir
  • js manifest• Powered by - Sprockets• application.js // FIXME: Tell people that this is a manifest file, real code should go into discrete files // //= require jquery //= require jquery_ujs //= require_tree .
  • SASS - no sprockets• probably don’t want to use manifests• use @import, or your variables and scopes will not work
  • Dev vs Production• To precompile, or not to precompile• Heroku • Cedar stack • counter-intuitive settings
  • Compression• Uglifier (for javascript)• SCSS (for css)
  • But, Why?
  • Identity Map
  • enabling• application.rb # Enable IdentityMap for Active Record, to disable set to false or remove the line below. config.active_record.identity_map = true
  • problems• associations• STI• tests
  • nestedhas_many :through
  • class Project < ActiveRecord::Base has_many :tasks has_many :assignments, :through => :tasks has_many :users, :through => :assignmentsend
  • Migrations
  • class CreateProjects < ActiveRecord::Migration def change create_table :projects do |t| t.string :name t.timestamps end endend
  • HTTP Streaming
  • requirements• Ruby 1.9.2 (min)• Web server support • nginx • unicorn
  • Examples
  • New App
  • Upgrade
  • Bundler• Did you know... you can use bundler all the way down to Rails 2.1 apps?
  • Add Bundler• http://youtu.be/7UzGdqaDnp8
  • • Upgrade the Gemfile• Config file changes• Move the assets
  • Configs• boot.rb• config.rb• development.rb• production.rb
  • Assets• Move asset folders• Fix image references• Manifests• stylesheet and javascript tag references
  • Upgrade Demo• Upgrading a Rails 2.1 app to Rails 3.1 in 1…