Top Banner
 Rails 3 Cool New Things
37

Rails 3 : Cool New Things

May 18, 2015

Download

Technology

Y. Thong Kuah

Cool new things in Rails 3. Presented at WellRailed at 27th January 2010
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Rails 3 : Cool New Things

   

Rails 3Cool New Things

Page 2: Rails 3 : Cool New Things

   

* Caveats

Page 3: Rails 3 : Cool New Things

   

Not ready...

● 3.0pre not released yet● http://oscardelben.com/articles/2009/12/06/how­

to­test­rails­3.html

Page 4: Rails 3 : Cool New Things

   

On to Cool Stuff...

Page 5: Rails 3 : Cool New Things

   

Have It Your Way

Page 6: Rails 3 : Cool New Things

   

More modular

● Standard Rails will work out of the box● Swap AR with DataMapper● http://www.slideshare.net/mattetti/rails3­

stepping­off­of­the­golden­path

Page 7: Rails 3 : Cool New Things

   

.....

Page 8: Rails 3 : Cool New Things

   

ActionController

● Based on Metal● Swap out stuff you don't need for performance● http://www.engineyard.com/blog/2010/rails­and­

merb­merge­plugin­api­part­3­of­6/

Page 9: Rails 3 : Cool New Things

   

Page 10: Rails 3 : Cool New Things

   

ActiveRecord & Arel

Page 11: Rails 3 : Cool New Things

   

Arel

● compose queries using relational algreba (http://github.com/rails/arel)

● Lazy loading in 3.1 (http://m.onkey.org/2010/1/22/active­record­query­interface)

Page 12: Rails 3 : Cool New Things

   

Arel

http://m.onkey.org/2010/1/22/active­record­query­interface

Page 13: Rails 3 : Cool New Things

   

Responders

● respond_to now baked in● Can make your own responders● http://weblog.rubyonrails.org/2009/8/31/three­

reasons­love­responder

Page 14: Rails 3 : Cool New Things

   http://www.engineyard.com/blog/2009/my­five­favorite­things­about­rails­3/

Page 15: Rails 3 : Cool New Things

   

New Gem Bundler

Page 16: Rails 3 : Cool New Things

   

Bundler

● No more config.gem● Gemfile● Evaluates all dependencies at once● Deploying and freezing native gems !● http://github.com/wycats/bundler

Page 17: Rails 3 : Cool New Things

   

Gemfile

Page 18: Rails 3 : Cool New Things

   

Config files *

● config/environment.rb shrunk● New file : config/application.rb ● Application name seems to matter now 

(https://rails.lighthouseapp.com/projects/8994/tickets/3556­app_generator­should­disallow­or­fix­invalid­app_const)

Page 19: Rails 3 : Cool New Things

   

config/environment.rb

Page 20: Rails 3 : Cool New Things

   

config/application.rb

Page 21: Rails 3 : Cool New Things

   

config/boot.rb

Page 22: Rails 3 : Cool New Things

   

RoutingMore power to the people

Page 23: Rails 3 : Cool New Things

   

Routing

● More flexible● Can point to any Rack application● “main#home == MainController.action(:home) 

== a Rack application”● http://yehudakatz.com/2009/12/26/the­rails­3­

router­rack­it­up/

Page 24: Rails 3 : Cool New Things

   

Routing

Page 25: Rails 3 : Cool New Things

   

Routing

Page 26: Rails 3 : Cool New Things

   

ActionMailer

● Looks more like a Controller now● http://gist.github.com/281420

Page 27: Rails 3 : Cool New Things

   

ActionMailer

http://gist.github.com/281420

Page 28: Rails 3 : Cool New Things

   

Javascript

Page 29: Rails 3 : Cool New Things

   

Javascript

● Unobtrusive● Easier to swap out with Jquery● Uses HTML5 data­* attributes

Page 30: Rails 3 : Cool New Things

   

Javascript

Page 31: Rails 3 : Cool New Things

   

Plugins

Page 32: Rails 3 : Cool New Things

   

Plugins

● rspec ­ http://github.com/dchelimsky/rspec­rails/tree/rails3

● cucumber http://blazingcloud.net/2010/01/17/notes­from­rails­3­bugmash

● Others http://wiki.rubyonrails.org/rails/version3/plugins_and_gems

Page 33: Rails 3 : Cool New Things

   

By the Way....

Page 34: Rails 3 : Cool New Things

   

Get Validations, etc by including ActiveModel::Validations

ActiveModel

Page 35: Rails 3 : Cool New Things

   

Rails::Subscriber

● Get hooks for notifications, etc.● E.g. Output ActiveRecord SQL to Growl● http://hasmanyquestions.wordpress.com/2010/0

1/17/let­your­sql­growl­in­rails­3/

Page 36: Rails 3 : Cool New Things

   

XSS protection

● eRB now escaped by default● Use raw to not escape● Try out the plugin 

http://github.com/NZKoz/rails_xss

Page 37: Rails 3 : Cool New Things

   

Starters

● http://omgbloglol.com/post/344792822/the­path­to­rails­3­introduction

● http://www.engineyard.com/blog/2009/my­five­favorite­things­about­rails­3/

● http://rails3.community­tracker.com/permalinks/5/notes­from­the­field­upgrading­to­rails­3