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
130
What is an API
jwo
0
190
DIY Rails Authentication
jwo
0
210
ActionCable - For Not Another Chat App
jwo
3
1.6k
SlackBot.rb - Create You a Slack Bot
jwo
1
1.4k
react-rails: an isomorphic match made in heaven
jwo
0
1.3k
Docker - next big thing
jwo
0
940
Ruby 2.1 Overview
jwo
0
960
Rails 4: Appetizers
jwo
1
970
Other Decks in Programming
See All in Programming
チームの境界をブチ抜いていけ
tokai235
0
190
AI駆動で0→1をやって見えた光と伸びしろ
passion0102
1
460
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
200
組込みだけじゃない!TinyGo で始める無料クラウド開発入門
otakakot
1
310
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
11
6.9k
ALL CODE BASE ARE BELONG TO STUDY
uzulla
25
6.3k
Claude Agent SDK を使ってみよう
hyshu
0
1.2k
Web フロントエンドエンジニアに開かれる AI Agent プロダクト開発 - Vercel AI SDK を観察して AI Agent と仲良くなろう! #FEC余熱NIGHT
izumin5210
3
560
なぜGoのジェネリクスはこの形なのか? Featherweight Goが明かす設計の核心
ryotaros
7
1.1k
Devvox Belgium - Agentic AI Patterns
kdubois
1
130
Catch Up: Go Style Guide Update
andpad
0
230
Server Side Kotlin Meetup vol.16: 内部動作を理解して ハイパフォーマンスなサーバサイド Kotlin アプリケーションを書こう
ternbusty
3
210
Featured
See All Featured
Visualization
eitanlees
149
16k
Code Reviewing Like a Champion
maltzj
526
40k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
Gamification - CAS2011
davidbonilla
81
5.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
980
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
115
20k
RailsConf 2023
tenderlove
30
1.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
44
7.8k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Documentation Writing (for coders)
carmenintech
75
5.1k
GraphQLとの向き合い方2022年版
quramy
49
14k
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