rails 3.1 sneak peak
DESCRIPTION
Sneak peak of Rails 3.1 new featuresTRANSCRIPT
What's new in Rails 3.1
Currently RC4, to be released soon
Aaron Patterson
Core team, in rc4 infoRails 3.1.0.rc4 has been released!
In a nutshell
• Asset Pipeline• HTTP streaming• JQuery by default• Reversible migrations• Mountable engines• Prepared statements
In a nutshell
• Rack::Cache on by default• Turn test-output on Ruby 1.9• Force SSL• Role-based mass-assignment
protection• BCrypt-based passwords• Custom serializers
There's always changelog
Assets pipeline
• Powered by Sprockets 2.0
Why use Sprockets?
1. Extract reusable code and share it across multiple web sites or applications.
2. Speed up your site by automatically concatenating JavaScript into a single file for production.
3. Organize your JavaScript source code into multiple commented files and directories.
4. Use bleeding-edge framework and library code in your application.
5. Sprockets is compatible with the PDoc JavaScript documentation system and the JavaScript framework of your choice.
Assets pipeline
• Enables proper organization, including use in plugins and engines
Assets pipeline
Js plugin example
plugins/color_picker/assets/images/color_picker/arrow.pngplugins/color_picker/assets/images/color_picker/circle.pngplugins/color_picker/assets/images/color_picker/hue.pngplugins/color_picker/assets/images/color_picker/saturation_and_brightness.pngplugins/color_picker/assets/stylesheets/color_picker.cssplugins/color_picker/src/color.jsplugins/color_picker/src/color_picker.js
color_picker.js:
//= require "color"//= provide "../assets"
When <color_picker> is required in your application, its provide directive will tell Sprockets that all files in the plugins/color_picker/assets/ directory should be copied into the web server's document root.
Assets pipeline
Compiling to one application.js//= require jquery//= require jquery_ujs//= require_tree .//= require 'independent_file'//= require 'super_lib'
Assets pipeline
“CoffeeScript is well done and more convenient to use
than JavaScript”- Brendan Eich, inventor of JavaScript
Assets pipeline
CoffeeScript
• Ruby-like syntax• Doesn't deprecate JavaScript code• OOP made easy (extends, etc)• Arrays with slicing and generators• Strings with interpolation and multi-line
Assets pipeline
CoffeeScript
Assets pipeline
CoffeeScript
http://asciicasts.com/episodes/267-coffeescript-basics
Assets pipeline
SASS
• Nesting• Variables• Mixins
Reversible migrations
Basic Auth