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
540
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
110
What is an API
jwo
0
180
DIY Rails Authentication
jwo
0
190
ActionCable - For Not Another Chat App
jwo
3
1.6k
SlackBot.rb - Create You a Slack Bot
jwo
1
1.3k
react-rails: an isomorphic match made in heaven
jwo
0
1.3k
Docker - next big thing
jwo
0
910
Ruby 2.1 Overview
jwo
0
930
Rails 4: Appetizers
jwo
1
940
Other Decks in Programming
See All in Programming
今ならAmazon ECSのサービス間通信をどう選ぶか / Selection of ECS Interservice Communication 2025
tkikuc
14
2.9k
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
140
C++20 射影変換
faithandbrave
0
500
F#で自在につくる静的ブログサイト - 関数型まつり2025
pizzacat83
0
310
Benchmark
sysong
0
240
Composerが「依存解決」のためにどんな工夫をしているか #phpcon
o0h
PRO
1
160
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
390
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
1
230
すべてのコンテキストを、 ユーザー価値に変える
applism118
2
500
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
220
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
290
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
240
Featured
See All Featured
Designing for humans not robots
tammielis
253
25k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Building Applications with DynamoDB
mza
95
6.5k
Fireside Chat
paigeccino
37
3.5k
Optimizing for Happiness
mojombo
379
70k
Typedesign – Prime Four
hannesfritz
42
2.7k
GraphQLとの向き合い方2022年版
quramy
46
14k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
What's in a price? How to price your products and services
michaelherold
246
12k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Music & Morning Musume
bryan
46
6.6k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
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