SlideShare una empresa de Scribd logo
1 de 46
Rails 3.1
  Lori Olson
 Confoo 2012
 Montreal, QC
Another new version of Rails.
 Delightful. And terrifying.
  What's 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
nested
has_many :through
class Project < ActiveRecord::Base
 has_many :tasks
 has_many :assignments, :through => :tasks
 has_many :users, :through => :assignments
end
Migrations
class CreateProjects < ActiveRecord::Migration

 def change

  create_table :projects do |t|

   t.string :name

   t.timestamps

  end

 end

end
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…

Más contenido relacionado

La actualidad más candente

Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
hannonhill
 

La actualidad más candente (20)

Why ruby and rails
Why ruby and railsWhy ruby and rails
Why ruby and rails
 
SFJS 6-19-2012
SFJS 6-19-2012SFJS 6-19-2012
SFJS 6-19-2012
 
SF Hadoop Users Group August 2014 Meetup Slides
SF Hadoop Users Group August 2014 Meetup SlidesSF Hadoop Users Group August 2014 Meetup Slides
SF Hadoop Users Group August 2014 Meetup Slides
 
PharoDAYS 2015: On Relational Databases by Guille Polito
PharoDAYS 2015: On Relational Databases by Guille PolitoPharoDAYS 2015: On Relational Databases by Guille Polito
PharoDAYS 2015: On Relational Databases by Guille Polito
 
Intro to Clojure 4 Developers
Intro to Clojure 4 DevelopersIntro to Clojure 4 Developers
Intro to Clojure 4 Developers
 
Coffeescript
CoffeescriptCoffeescript
Coffeescript
 
Javascript now and in the future
Javascript now and in the futureJavascript now and in the future
Javascript now and in the future
 
Ship It ! with Ruby/ Rails Ecosystem
Ship It ! with Ruby/ Rails EcosystemShip It ! with Ruby/ Rails Ecosystem
Ship It ! with Ruby/ Rails Ecosystem
 
Gatsby vs. Next.js
Gatsby vs. Next.jsGatsby vs. Next.js
Gatsby vs. Next.js
 
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScriptJS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
 
Through Meteor to the stars - Developing full-stack SPA's with meteor.js
Through Meteor to the stars - Developing full-stack SPA's with meteor.jsThrough Meteor to the stars - Developing full-stack SPA's with meteor.js
Through Meteor to the stars - Developing full-stack SPA's with meteor.js
 
Can i Get C# for Free ?
Can i Get C# for Free ?Can i Get C# for Free ?
Can i Get C# for Free ?
 
Lisp in the Cloud
Lisp in the CloudLisp in the Cloud
Lisp in the Cloud
 
[Rakuten TechConf2014] [C-2] Big Data for eBooks and eReaders
[Rakuten TechConf2014] [C-2] Big Data for eBooks and eReaders[Rakuten TechConf2014] [C-2] Big Data for eBooks and eReaders
[Rakuten TechConf2014] [C-2] Big Data for eBooks and eReaders
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 
Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*
 
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
 
Ruby on Rails Workshop
Ruby on Rails WorkshopRuby on Rails Workshop
Ruby on Rails Workshop
 
[CocoaHeads Tricity] Michał Zygar - Consuming API
[CocoaHeads Tricity] Michał Zygar - Consuming API[CocoaHeads Tricity] Michał Zygar - Consuming API
[CocoaHeads Tricity] Michał Zygar - Consuming API
 
Server Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.jsServer Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.js
 

Similar a Rails 3.1

Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
Wen-Tien Chang
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Nilesh Panchal
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
Avi Kedar
 
Jasig rubyon rails
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails
_zaMmer_
 
Jasig rubyon rails
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails
_zaMmer_
 

Similar a Rails 3.1 (20)

RubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipelineRubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipeline
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
 
OSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsOSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy Hawkins
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Rails 5 subjective overview
Rails 5 subjective overviewRails 5 subjective overview
Rails 5 subjective overview
 
Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXC
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
Frontend as a first class citizen
Frontend as a first class citizenFrontend as a first class citizen
Frontend as a first class citizen
 
Be faster then rabbits
Be faster then rabbitsBe faster then rabbits
Be faster then rabbits
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Untangling - fall2017 - week 8
Untangling - fall2017 - week 8Untangling - fall2017 - week 8
Untangling - fall2017 - week 8
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swagger
 
Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Review
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Kubernetes Manchester - 6th December 2018
Kubernetes Manchester - 6th December 2018Kubernetes Manchester - 6th December 2018
Kubernetes Manchester - 6th December 2018
 
Workflow Engines for Hadoop
Workflow Engines for HadoopWorkflow Engines for Hadoop
Workflow Engines for Hadoop
 
Polyglot Grails
Polyglot GrailsPolyglot Grails
Polyglot Grails
 
Jasig rubyon rails
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails
 
Jasig rubyon rails
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails
 

Más de Lori Olson

Más de Lori Olson (7)

Do The Work
Do The WorkDo The Work
Do The Work
 
Rockstars & Consultants, who needs 'em
Rockstars & Consultants, who needs 'emRockstars & Consultants, who needs 'em
Rockstars & Consultants, who needs 'em
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion Introduction
 
Mobile rage
Mobile rageMobile rage
Mobile rage
 
Maps and Scale
Maps and ScaleMaps and Scale
Maps and Scale
 
Rockstars & Consultants - who needs 'em
Rockstars & Consultants - who needs 'emRockstars & Consultants - who needs 'em
Rockstars & Consultants - who needs 'em
 
Powerful UX, not just for desktops anymore
Powerful UX, not just for desktops anymorePowerful UX, not just for desktops anymore
Powerful UX, not just for desktops anymore
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Rails 3.1

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. 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
  6. 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
  7. gem &apos;jquery-rails&apos; or gem &apos;prototype-rails&apos; 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
  8. Almost 10x more popular than Prototype\n\nPopularity == ecosystem\n\nVersioning... rails dictates which jQuery version now, which is better\n
  9. Infographic\nfile:///Volumes/loriolson/Confoo/Javascript%20Frameworks%20and%20jQuery%20(Infographic)%20%7C%20Web%20Resources%20%7C%20WebAppers.webarchive\n
  10. \n
  11. But it&amp;#x2019;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&amp;#x2019;t spend a lot of time on it.\n\n
  12. Thomas Fuchs, author of the Scriptaculous framework, co-author of the JavaScript Performance Rocks! ebook had this to say about CoffeeScript\n
  13. However, if you really want to learn it, and I suggest you do, there are some great resources out there. \n
  14. Syntactically Awesome Stylesheets\n
  15. \n
  16. Guess which one is recommended? ;-)\n
  17. \n
  18. \n
  19. It makes CSS and JavaScript first-class code citizens and enables proper organization, including use in plugins and engines\n
  20. So, the assets (images, javascripts, &amp; stylesheets) have been tucked under public, all this time.\n\nNow, they are slotted in under the app/assets directory\n
  21. So, the assets (images, javascripts, &amp; stylesheets) have been tucked under public, all this time.\n\nNow, they are slotted in under the app/assets directory\n
  22. So, the assets (images, javascripts, &amp; stylesheets) have been tucked under public, all this time.\n\nNow, they are slotted in under the app/assets directory\n
  23. So, the assets (images, javascripts, &amp; stylesheets) have been tucked under public, all this time.\n\nNow, they are slotted in under the app/assets directory\n
  24. \n
  25. \n
  26. generate something to run on heroku to demo diff\n
  27. \n
  28. Average load time\nNumber of resource requests\nCDN\n\n
  29. 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
  30. \n
  31. \n
  32. \n
  33. Didn&amp;#x2019;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
  34. change\n
  35. Instead of up and down. This works for straight-forward migrations, but if you are doing something special, you will probably still want up &amp; down.\n
  36. 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
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n