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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
DamirSvrtan
September 14, 2015
Programming
0
63
Responders
Dry-out your controllers with some responders
DamirSvrtan
September 14, 2015
Tweet
Share
More Decks by DamirSvrtan
See All by DamirSvrtan
Designing APIs: Less Data is More
damirsvrtan
1
510
Crossing Domain Boundaries with GraphQL
damirsvrtan
0
190
Surrounded by Microservices
damirsvrtan
2
5.5k
Building Serverless Ruby Bots @ Ruby Conf 2018
damirsvrtan
0
460
Building Serverless Ruby Bots @ Paris.rb Conf 2018
damirsvrtan
1
2.5k
Importing and serving millions of records
damirsvrtan
1
200
Stateless authentication w/ JSON Web Tokens
damirsvrtan
5
350
Building Ruby Bots on AWS Lambda
damirsvrtan
0
1.3k
Reinventing The Bootcamp Idea
damirsvrtan
0
240
Other Decks in Programming
See All in Programming
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
150
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
610
我々はなぜ「層」を分けるのか〜「関心の分離」と「抽象化」で手に入れる変更に強いシンプルな設計〜 #phperkaigi / PHPerKaigi 2026
shogogg
2
210
Codex の「自走力」を高める
yorifuji
0
1.3k
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
270
Nostalgia Meets Technology: Super Mario with TypeScript
manfredsteyer
PRO
0
100
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
140
Windows on Ryzen and I
seosoft
0
350
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
550
CS教育のDX AIによる育成の効率化
niftycorp
PRO
0
150
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
170
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
37
7.2k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
150
Joys of Absence: A Defence of Solitary Play
codingconduct
1
320
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
200
How to build a perfect <img>
jonoalderson
1
5.3k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
120
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
690
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.2k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
130
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
400
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.