SlideShare a Scribd company logo
1 of 29
Download to read offline
What’s new in
4.1(Chennai.rb March meetup)
(@vysakh0)
Vysakh Sreenivasan
Just want to build cool apps for me and
others
- Rails app probably take around ~5
seconds to boot.
- 50 times a day (test, rails s, rails g...)
i.e You waste 5days in a YEAR
#1 Spring preloader
built in integration in Rails 4.1
keeps app running in the background
No booting every time you run a test,
rake task or migration
PARTY IN THOSE 5 DAYS
How do you load api keys in Rails?
- create .yml, .rb file and load or
- figaro gem or
- dotenv gem.
#2 config/secrets.yml
generated by Rails 4.1
Just put your api keys in secrets.yml
# config/secrets.yml
development:
facebook_consumer_key: “random skdfjks”
facebook_consumer_secret: “its a secret”
# config/secrets.yml
development:
facebook_consumer_key: “random key”
facebook_consumer_secret: “its a secret”
# config/initializers/devise.rb
…..
config.omniauth :facebook, Rails.application.secrets.facebook_consumer_key , Rails.
application.secrets.facebook_consumer_secret
…..
Just use it like this
Config
How do you change the state of Order
- to pending.
- to completed.
- to refunded
Create separate columns?
- completed(:boolean) , refunded(:boolean)
Create an integer column?
- 0 -> pending
- 1 -> completed
- 2-> refunded
#3 Active Record enums
in Rails 4.1
# app/modes/order.rb
class Order < ActiveRecord::Base
# status is an integer column in orders table
enum status: {
pending: 0,
completed: 1,
refunded: 2
}
end
Now enum gives us
handy helper methods
@order.pending?
@order.completed!
@order.completed?
@order.refunded!
@order.refunded?
#4 Application Message Verifier
built in helper in Rails 4.1
irb> @user.id
# => 1
irb> user_token = Rails.application.message_verifier
(“remember_me”). generate(@user.id)
=> "BAhpBg==--859750a419640d18d7c24e3166541a9405a42786"
irb> get_back_user_id = Rails.application.
message_verifier(“remember_me”). verify(user_token)
=> 1
USE CASES
- Password reset
- Invite links
- Oauth tokens
- and more
Show different templates to
phone/browsers/tablets ?
#5 Application Pack Variants
(Code example taken from
http://coherence.io/blog/2013/12/17/whats-new-in-rails-4-1.html )
class ApplicationController < ActionController ::Base
before_action :detect_device_variant
private
def detect_device_variant
case request.user_agent
when /iPad/i
request.variant = :tablet
when /iPhone/i
request.variant = :phone
end
end
end
class PostController < ApplicationController
def show
@post = Post.find(params[:id])
respond_to do |format|
format.json
format.html # /app/views/posts/show.html.erb
format.html.phone # /app/views/posts/show.html+phone.erb
format.html.tablet do
@show_edit_link = false
end
end
end
end
#6 Application Mailer Previews
class NotifierPreview < ActionMailer::Preview
def welcome
Notifier.welcome(User.first)
end
end
# test/mailers/notifier_preview.rb
List of all mailer previews
http://localhost:3000/rails/mailers
What's new in Rails 4.1

More Related Content

What's hot

11.05.21 Google I/O報告会 in 東京 なかざわ資料
11.05.21 Google I/O報告会 in 東京 なかざわ資料11.05.21 Google I/O報告会 in 東京 なかざわ資料
11.05.21 Google I/O報告会 in 東京 なかざわ資料
Kei Nakazawa
 
Automate_Android_development_brief_20161015
Automate_Android_development_brief_20161015Automate_Android_development_brief_20161015
Automate_Android_development_brief_20161015
Elvis Lin
 

What's hot (20)

Angular js fundamentals
Angular js fundamentalsAngular js fundamentals
Angular js fundamentals
 
ExpressionEngine 2: Total Domination
ExpressionEngine 2: Total DominationExpressionEngine 2: Total Domination
ExpressionEngine 2: Total Domination
 
ASP.NET Core 2.0 - Best Practices per le Web API
ASP.NET Core 2.0 - Best Practices per le Web APIASP.NET Core 2.0 - Best Practices per le Web API
ASP.NET Core 2.0 - Best Practices per le Web API
 
Integrate Jenkins with S3
Integrate Jenkins with S3Integrate Jenkins with S3
Integrate Jenkins with S3
 
11.05.21 Google I/O報告会 in 東京 なかざわ資料
11.05.21 Google I/O報告会 in 東京 なかざわ資料11.05.21 Google I/O報告会 in 東京 なかざわ資料
11.05.21 Google I/O報告会 in 東京 なかざわ資料
 
Tech saloniki - Cross platform mobile development using xamarin
Tech saloniki  - Cross platform mobile development using xamarinTech saloniki  - Cross platform mobile development using xamarin
Tech saloniki - Cross platform mobile development using xamarin
 
AWS Tech Summit - Berlin 2011 - Running Java Applications on AWS
AWS Tech Summit - Berlin 2011 - Running Java Applications on AWSAWS Tech Summit - Berlin 2011 - Running Java Applications on AWS
AWS Tech Summit - Berlin 2011 - Running Java Applications on AWS
 
Deploy, Manage & Scale Your Apps with Elastic Beanstalk
Deploy, Manage & Scale Your Apps with Elastic BeanstalkDeploy, Manage & Scale Your Apps with Elastic Beanstalk
Deploy, Manage & Scale Your Apps with Elastic Beanstalk
 
Automate_Android_development_brief_20161015
Automate_Android_development_brief_20161015Automate_Android_development_brief_20161015
Automate_Android_development_brief_20161015
 
FITC 2012 Jellybean Tips and Tricks
FITC 2012 Jellybean Tips and TricksFITC 2012 Jellybean Tips and Tricks
FITC 2012 Jellybean Tips and Tricks
 
Let's do SPA
Let's do SPALet's do SPA
Let's do SPA
 
API 101 Workshop from APIStrat Conference
API 101 Workshop from APIStrat ConferenceAPI 101 Workshop from APIStrat Conference
API 101 Workshop from APIStrat Conference
 
Selenium training in Chennai
Selenium training in Chennai Selenium training in Chennai
Selenium training in Chennai
 
Flashr: Flash and the Flickr API
Flashr: Flash and the Flickr APIFlashr: Flash and the Flickr API
Flashr: Flash and the Flickr API
 
Fun! with the Twitter API
Fun! with the Twitter APIFun! with the Twitter API
Fun! with the Twitter API
 
I'm not a child anymore
I'm not a child anymoreI'm not a child anymore
I'm not a child anymore
 
Mobile and API identity – The New Challenges
Mobile and API identity – The New ChallengesMobile and API identity – The New Challenges
Mobile and API identity – The New Challenges
 
How to – rest api proxy to soap webservice
How to – rest api proxy to soap webserviceHow to – rest api proxy to soap webservice
How to – rest api proxy to soap webservice
 
すぐ使える!入門API設計ワークショップ
すぐ使える!入門API設計ワークショップすぐ使える!入門API設計ワークショップ
すぐ使える!入門API設計ワークショップ
 
REST APIs, Girls Who Code
REST APIs, Girls Who CodeREST APIs, Girls Who Code
REST APIs, Girls Who Code
 

Viewers also liked (6)

Caching in rails
Caching in railsCaching in rails
Caching in rails
 
Django in Eclipse
Django in EclipseDjango in Eclipse
Django in Eclipse
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Rebooting the Blue Button
Rebooting the Blue ButtonRebooting the Blue Button
Rebooting the Blue Button
 
Javascript 교육자료 pdf
Javascript 교육자료 pdfJavascript 교육자료 pdf
Javascript 교육자료 pdf
 

Similar to What's new in Rails 4.1

An introduction-to-ruby-on-rails
An introduction-to-ruby-on-railsAn introduction-to-ruby-on-rails
An introduction-to-ruby-on-rails
vinicorp
 
An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506
Vu Hung Nguyen
 

Similar to What's new in Rails 4.1 (20)

Rails 5 – most effective features for apps upgradation
Rails 5 – most effective features for apps upgradationRails 5 – most effective features for apps upgradation
Rails 5 – most effective features for apps upgradation
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Rails and the Apache SOLR Search Engine
Rails and the Apache SOLR Search EngineRails and the Apache SOLR Search Engine
Rails and the Apache SOLR Search Engine
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Create a new project in ROR
Create a new project in RORCreate a new project in ROR
Create a new project in ROR
 
Laravel Code Generators and Packages
Laravel Code Generators and PackagesLaravel Code Generators and Packages
Laravel Code Generators and Packages
 
YAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl CodingYAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl Coding
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
 
Lightweight web frameworks
Lightweight web frameworksLightweight web frameworks
Lightweight web frameworks
 
Top 8 Ruby on Rails Gems
Top 8 Ruby on Rails GemsTop 8 Ruby on Rails Gems
Top 8 Ruby on Rails Gems
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 
Flex And Rails
Flex And RailsFlex And Rails
Flex And Rails
 
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
 
Intro to Rails
Intro to Rails Intro to Rails
Intro to Rails
 
An introduction-to-ruby-on-rails
An introduction-to-ruby-on-railsAn introduction-to-ruby-on-rails
An introduction-to-ruby-on-rails
 
An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overview
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
 

More from Vysakh Sreenivasan (6)

Introduction to Vim, the text editor
Introduction to Vim, the text editorIntroduction to Vim, the text editor
Introduction to Vim, the text editor
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced Ruby
 
Ruby on Rails for beginners
Ruby on Rails for beginnersRuby on Rails for beginners
Ruby on Rails for beginners
 
Building Rich Ruby on Rails with Emberjs
Building Rich Ruby on Rails with EmberjsBuilding Rich Ruby on Rails with Emberjs
Building Rich Ruby on Rails with Emberjs
 
Introduction to vim
Introduction to vimIntroduction to vim
Introduction to vim
 

Recently uploaded

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
 
+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@
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
+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...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 

What's new in Rails 4.1