Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rails is Just Ruby
Search
Jesse Wolgamott
April 29, 2013
Programming
1
530
Rails is Just Ruby
RailsConf 2013 - Intro Track
Jesse Wolgamott
April 29, 2013
Tweet
Share
More Decks by Jesse Wolgamott
See All by Jesse Wolgamott
React vs React-Native
jwo
0
100
What is an API
jwo
0
180
DIY Rails Authentication
jwo
0
180
ActionCable - For Not Another Chat App
jwo
3
1.4k
SlackBot.rb - Create You a Slack Bot
jwo
1
1.3k
react-rails: an isomorphic match made in heaven
jwo
0
1.2k
Docker - next big thing
jwo
0
870
Ruby 2.1 Overview
jwo
0
880
Rails 4: Appetizers
jwo
1
900
Other Decks in Programming
See All in Programming
CloudNativePGがCNCF Sandboxプロジェクトになったぞ! 〜CloudNativePGの仕組みの紹介〜
nnaka2992
0
190
watsonx.ai Dojo #6 継続的なAIアプリ開発と展開
oniak3ibm
PRO
0
270
ErdMap: Thinking about a map for Rails applications
makicamel
1
1.1k
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
170
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
3
310
ファインディの テックブログ爆誕までの軌跡
starfish719
1
790
Simple組み合わせ村から大都会Railsにやってきた俺は / Coming to Rails from the Simple
moznion
3
3.7k
Amazon Bedrock Multi Agentsを試してきた
tm2
1
220
Amazon ECS とマイクロサービスから考えるシステム構成
hiyanger
1
180
ASP.NET Core の OpenAPIサポート
h455h1
0
160
ISUCON14公式反省会LT: 社内ISUCONの話
astj
PRO
0
140
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
240
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
39
1.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Designing Experiences People Love
moore
139
23k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
520
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
Optimising Largest Contentful Paint
csswizardry
33
3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
We Have a Design System, Now What?
morganepeng
51
7.4k
Bash Introduction
62gerente
610
210k
Transcript
Ruby is Just Rails A Guide to Procrastination and Happiness
Stu Rails makes insanely easy Seemingly Magical
Protect entire system from unauthorized requests Seemingly Magical
Log every page load Seemingly Magical
Update full-text search engine every time a record is added
Seemingly Magical
it’s not magic Magic It’s not magic (maybe at first)
http:/ /lotr.wikia.com/wiki/File:Gandalf-2.jpg
http:/ /www.ibeta.eu/blog/darth-vader-on-tedxeutropolis/
Wizard Like Powers Business People consider us wizards with our
ability to create business value
Rails Helps us Along Rails helps us along
Rails Helps us Along Blocks
Rails Helps us Along Before Filters
Rails Helps us Along Callbacks
Rails Helps us Along Inheritance
Rails Helps us Along It all starts with a block
The Block
10.times do puts "YOLO" end
None
@users.each do |user| <%= user.email %> end
User.create do |u| u.name = 'jwo' end
@users.map {|u| u.total_due }.sum
Rails Helps us Along code that gets delayed and executed
later
Block Rules Every Ruby method can receive a block
Block Rules The method has to yield to the block
to be e ective
Block Rules Can take parameters and won’t scream if you
send in too few
args.each do |key,value| end
Advanced Blocks Advanced Block Tips
Block Rules Don’t use ‘return’ in a block
Block Rules Use Ruby’s implicit returns instead
Advanced Blocks Add retries for volatile actions
10.times.retry do SomeNetworkCommunicationThingyHere.new end https://github.com/schneems/rrrretry
Before Filters
Before Filters Used in Controllers
Before Filters Rails actions are your interactions with users (get/post
data)
Before Filters Can be before or after
Before Filters If your before filter returns, or redirects the
action won’t happen
before_filter do |controller| unless controller.send(:logged_in?) redirect_to new_login_url end end
class ApplicationController before_filter :authenticate_user def authenticate_user unless logged_in? redirect_to new_login_url
end end end
class PostsController < AppController # already secured end
class PublicPostsController < AppController skip_before_filter :authenticate_user end
Callbacks
About Callbacks Code you can define to run later works
in Models too
About Callbacks It’s like HollaBack, but not
Callback Example Stack Overflow Example: Downcasing email
class User < ActiveRecord::Base before_validation do |user| user.email = user.email.downcase
end end
Callback Example Real World Example: Full Text Searching (websolr)
class Post < ActiveRecord::Base searchable do text :title, :body end
end https://github.com/sunspot/sunspot
Post.search do fulltext 'best pizza' end https://github.com/sunspot/sunspot
after_destroy do |searchable| searchable.remove_from_index end https://github.com/sunspot/sunspot/blob/master/ sunspot_rails/lib/sunspot/rails/searchable.rb
Workshop Time
Workshop Create a beeper alert program
Workshop Criteria if alarm is critical, send SMS
Workshop Criteria if alarm is warning, send email
I’m JWo Thanks! @jwo Jesse Wolgamott.com