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
Responders
Search
DamirSvrtan
September 14, 2015
Programming
70
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Responders
Dry-out your controllers with some responders
DamirSvrtan
September 14, 2015
More Decks by DamirSvrtan
See All by DamirSvrtan
Designing APIs: Less Data is More
damirsvrtan
1
530
Crossing Domain Boundaries with GraphQL
damirsvrtan
0
210
Surrounded by Microservices
damirsvrtan
2
5.5k
Building Serverless Ruby Bots @ Ruby Conf 2018
damirsvrtan
0
480
Building Serverless Ruby Bots @ Paris.rb Conf 2018
damirsvrtan
1
2.6k
Importing and serving millions of records
damirsvrtan
1
220
Stateless authentication w/ JSON Web Tokens
damirsvrtan
5
380
Building Ruby Bots on AWS Lambda
damirsvrtan
0
1.3k
Reinventing The Bootcamp Idea
damirsvrtan
0
280
Other Decks in Programming
See All in Programming
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
1k
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
170
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
380
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
2
430
どこまでゆるくて許されるのか
tk3fftk
0
310
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
450
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
240
霧の中の代数的エフェクト
funnyycat
1
200
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
0
140
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.7k
自作OSでスライド発表する
uyuki234
1
3.6k
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
380
Unsuck your backbone
ammeep
672
58k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
310
The Curious Case for Waylosing
cassininazir
1
420
New Earth Scene 8
popppiees
3
2.4k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
So, you think you're a good person
axbom
PRO
2
2.1k
Statistics for Hackers
jakevdp
799
230k
The agentic SEO stack - context over prompts
schlessera
0
840
Transcript
Responders
©2015 Infinum student academy PostsController#create @post = Post.new(post_params) if @post.save(post_params)
redirect_to @post flash[:notice] = 'Post was successfully updated.' else render :new end
©2015 Infinum student academy What about internationalization?
©2015 Infinum student academy PostsController#create @post = Post.new(post_params) if @post.save
flash[:notice] = I18n.t(‘flash.posts.create.notice’) redirect_to @post else render :new end
©2015 Infinum student academy The update action is very similar
©2015 Infinum student academy PostsController#update @post = Post.find(params[:id]) if @post.update(post_params)
flash[:notice] = I18n.t(‘flash.posts.update.notice’) redirect_to @post else render :edit end
©2015 Infinum student academy The restful controller pseudocode: initialize_resource can
it be saved? flash redirect else render end
Meet the responders..
©2015 Infinum student academy Convenient wrappers for REST controllers @post
= Post.create(post_params) respond_with @post
©2015 Infinum student academy Knows what translation to look at
©2015 Infinum student academy Universal translation for all controllers flash:
actions: create: notice: "%{resource_name} was successfully created." update: notice: "%{resource_name} was successfully updated." destroy: notice: "%{resource_name} was successfully destroyed." alert: "%{resource_name} could not be destroyed."
©2015 Infinum student academy Translation per controller flash: posts: create:
notice: "Your post was created and will be published soon"
©2015 Infinum student academy Need a non-standard redirect location? @post
= Post.create(post_params) respond_with @post, location: -> { posts_path }
©2015 Infinum student academy Need a non-standard rendering template? @post
= Post.create(post_params) respond_with @post, action: ‘shared/posts/new’
History
©2015 Infinum student academy Responders • Extracted from Rails 4.2
to a separate gem • Maintained by Plataformatec • authors of Devise & Simple Form
©2015 Infinum student academy Why were they extracted from Rails?
©2015 Infinum student academy respond_to do |format| format.xml { render
xml: @model } format.json { render json: @model } end is clearer than… respond_with @model
©2015 Infinum student academy I only use them for Html
API’s
Fin.