What's new in Rails 4.1 (as of 752f9fed00221ad97073e13b12be9c849199b4b8)

Godfrey Chan
Godfrey ChanFounder at caliper.io
Hello #VANRUBY!
Godfrey Chan
  @chancancode
What's new in Rails 4.1 (as of 752f9fed00221ad97073e13b12be9c849199b4b8)
What's new in Rails 4.1 (as of 752f9fed00221ad97073e13b12be9c849199b4b8)
PUBLIC SERVICE
ANNOUNCEMENT
RAILS 3.2.16 + 4.0.2
http://groups.google.com/group/rubyonrails-security
What’s NEW IN
Rails 4.1 *
* As OF 752f9fed00221ad97073e13b12be9c849199b4b8
VARIANTS
Variants
Variants
class ApplicationController < ActionController::Base
before_action :detect_variant
 
private
 
def detect_variant
request.variant = 
case request.user_agent
when /iPhone/ then :phone
when /iPad/
then :tablet
end
end
end

respond_to do |format|
format.html do |html|
html.phone
# index.html+phone.erb
html.tablet do # index.html+tablet.erb
# ...
render
end
end
end
Variants

OTHER USES...
A/B TESTING?
API VERSIONING?
OLD BROWSERS?
NO JS FALLBACK?
ENUMS
ENUMS
class Conversation < ActiveRecord::Base
enum status: [ :active, :archived ]
end
conversation.archive!
conversation.active? # => false
conversation.status # => "archived"
Conversation.archived # => Relation for all archived Conversations
MESSAGE VERIFIER
MESSAGE VERIFIER
message = Rails.application
.message_verifier('salt')
.generate('my sensible data')
 
Rails.application
.message_verifier('salt')
.verify(message) # => 'my sensible data'
MESSAGE VERIFIER
USES...
PASSWORD RESET?
INVITE TOKEN?
OTHER LINKS IN EMAILS?
TIME TRAVEL
TIME TRAVEL
TIME TRAVEL
test "Fast forward to Christmas" do
refute is_it_christmas_yet?
travel_to Time.new(2013, 12, 25, 00, 00, 00)
assert is_it_christmas_yet?
end
 
test "How I met your mother" do
@mother = User.find(...)
travel -30.years do
assert @mother.single?
end
refute @mother.single?
end
SPRING
Rails application preloader
Totally AutomatICGIc
spring
$ time ./bin/rails runner 'puts "Hello"'
Hello
0.05s user 0.02s system 1% cpu 3.860 total
$ time ./bin/rails runner 'puts "Hello"'
Hello
0.05s user 0.01s system 27% cpu 0.229 total

$ time ./bin/rake spec

.............................................................................................
 
Finished in 15.04 seconds
322 examples, 0 failures
 
0.06s user 0.02s system 0% cpu 25.446 total
 
$ time ./bin/rake spec

.............................................................................................
 
Finished in 14.79 seconds
322 examples, 0 failures
 
0.05s user 0.01s system 0% cpu 20.543 total
spring
NO TOUCHING
NO TOUCHING
ActiveRecord::Base.no_touching do
Post.first.touch # does nothing
end
 
Comment.no_touching do
Comment.first.touch # does nothing
Post.first.touch # updates, but won't update related comments if there are any
end
TO_PARAM
_
TO_PARAM
class User < ActiveRecord::Base
to_param :name
end
 
user = User.find_by(name: 'Fancy Pants')
user.id
# => 123
user.to_param # => "123-fancy-pants"
String#Remove
String#Remove
>> ' a lot of
whitespace
=> "alotofwhitespace"

'.remove(/[:space:]/)

>> 'username=godfrey&password=123456'.remove(/&?password=[^&]*/)
=> "username=godfrey"
JSON
r.i.p. multijson
all-New JSON encoder
Action view
SURPRISES?
TRY IT TODAY

https://gist.github.com/chancancode/7781341
TRY IT TODAY
# Gemfile
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
#VANRUBY + OSS
= <3 <3 <3 <3
Hack night TUE dec 17
IRC #VANRUBY (freenode)
Godfrey Chan
  @chancancode
1 of 41

Recommended

10 Golden Rules For Outstanding Titanium Apps by
 10 Golden Rules For Outstanding Titanium Apps 10 Golden Rules For Outstanding Titanium Apps
10 Golden Rules For Outstanding Titanium Appsjamessugrue
8.3K views59 slides
Titanium @ Minnebar by
Titanium @ MinnebarTitanium @ Minnebar
Titanium @ MinnebarKevin Whinnery
706 views20 slides
Apps with Apache Cordova and Phonegap by
Apps with Apache Cordova and PhonegapApps with Apache Cordova and Phonegap
Apps with Apache Cordova and PhonegapChristian Grobmeier
29.7K views33 slides
Apache Cordova, Hybrid Application Development by
Apache Cordova, Hybrid Application DevelopmentApache Cordova, Hybrid Application Development
Apache Cordova, Hybrid Application Developmentthedumbterminal
1.5K views13 slides
Hot and spicy Java with Lombok. Live! by
Hot and spicy Java with Lombok. Live!Hot and spicy Java with Lombok. Live!
Hot and spicy Java with Lombok. Live!Vladimir Tsukur
2.2K views27 slides
Lecture1 oopj by
Lecture1 oopjLecture1 oopj
Lecture1 oopjDhairya Joshi
214 views3 slides

More Related Content

Similar to What's new in Rails 4.1 (as of 752f9fed00221ad97073e13b12be9c849199b4b8)

Rupicon 2014 Action pack by
Rupicon 2014 Action packRupicon 2014 Action pack
Rupicon 2014 Action packrupicon
446 views17 slides
Building Mobile Friendly APIs in Rails by
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsJim Jeffers
2.8K views110 slides
Elixir と Maru で REST API by
Elixir と Maru で REST APIElixir と Maru で REST API
Elixir と Maru で REST APIKohei Kimura
1.4K views13 slides
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium by
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with AppiumSrijan Technologies
536 views43 slides
Don't screw it up! How to build durable API by
Don't screw it up! How to build durable API Don't screw it up! How to build durable API
Don't screw it up! How to build durable API Alessandro Cinelli (cirpo)
2.6K views169 slides
State ofappdevelopment by
State ofappdevelopmentState ofappdevelopment
State ofappdevelopmentgillygize
397 views39 slides

Similar to What's new in Rails 4.1 (as of 752f9fed00221ad97073e13b12be9c849199b4b8)(20)

Rupicon 2014 Action pack by rupicon
Rupicon 2014 Action packRupicon 2014 Action pack
Rupicon 2014 Action pack
rupicon446 views
Building Mobile Friendly APIs in Rails by Jim Jeffers
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
Jim Jeffers2.8K views
Elixir と Maru で REST API by Kohei Kimura
Elixir と Maru で REST APIElixir と Maru で REST API
Elixir と Maru で REST API
Kohei Kimura1.4K views
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium by Srijan Technologies
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
State ofappdevelopment by gillygize
State ofappdevelopmentState ofappdevelopment
State ofappdevelopment
gillygize397 views
Mobile Development with PhoneGap by Daniel Ramos
Mobile Development with PhoneGapMobile Development with PhoneGap
Mobile Development with PhoneGap
Daniel Ramos2.8K views
Phone gap by Ali Dany
Phone gapPhone gap
Phone gap
Ali Dany921 views
Building Cross-Platform Mobile Apps by Troy Miles
Building Cross-Platform Mobile AppsBuilding Cross-Platform Mobile Apps
Building Cross-Platform Mobile Apps
Troy Miles1K views
Architecting applications for Windows 8 and Windows Phone 8 by Karl Ots / @f... by Karl Ots
Architecting applications for Windows 8 and Windows Phone 8  by Karl Ots / @f...Architecting applications for Windows 8 and Windows Phone 8  by Karl Ots / @f...
Architecting applications for Windows 8 and Windows Phone 8 by Karl Ots / @f...
Karl Ots1.2K views
Android Services Skill Sprint by Jim McKeeth
Android Services Skill SprintAndroid Services Skill Sprint
Android Services Skill Sprint
Jim McKeeth2.5K views
Flutter technology Based on Web Development by divyawani2
Flutter technology Based on Web Development Flutter technology Based on Web Development
Flutter technology Based on Web Development
divyawani2126 views
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless... by Whymca
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...
Whymca658 views
Best Practices in apps development with Titanium Appcelerator by Alessio Ricco
Best Practices in apps development with Titanium Appcelerator Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator
Alessio Ricco36.9K views
Cross platform mobile apps using .NET by Jonas Follesø
Cross platform mobile apps using .NETCross platform mobile apps using .NET
Cross platform mobile apps using .NET
Jonas Follesø4.2K views
Voiture tech talk by Hoppinger
Voiture tech talkVoiture tech talk
Voiture tech talk
Hoppinger502 views

Recently uploaded

Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen... by
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...NUS-ISS
28 views70 slides
.conf Go 2023 - Data analysis as a routine by
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routineSplunk
93 views12 slides
Black and White Modern Science Presentation.pptx by
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptxmaryamkhalid2916
14 views21 slides
Data-centric AI and the convergence of data and model engineering: opportunit... by
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...Paolo Missier
34 views40 slides
The details of description: Techniques, tips, and tangents on alternative tex... by
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...BookNet Canada
121 views24 slides
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Safe Software
225 views86 slides

Recently uploaded(20)

Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen... by NUS-ISS
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
NUS-ISS28 views
.conf Go 2023 - Data analysis as a routine by Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk93 views
Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 views
Data-centric AI and the convergence of data and model engineering: opportunit... by Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier34 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada121 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software225 views
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor... by Vadym Kazulkin
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
Vadym Kazulkin75 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi120 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma17 views
Combining Orchestration and Choreography for a Clean Architecture by ThomasHeinrichs1
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs169 views
Spesifikasi Lengkap ASUS Vivobook Go 14 by Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst470 views
Web Dev - 1 PPT.pdf by gdsczhcet
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet55 views
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu... by NUS-ISS
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
NUS-ISS37 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman27 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf

What's new in Rails 4.1 (as of 752f9fed00221ad97073e13b12be9c849199b4b8)