Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Responders
Search
DamirSvrtan
September 14, 2015
Programming
76
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
570
Crossing Domain Boundaries with GraphQL
damirsvrtan
0
230
Surrounded by Microservices
damirsvrtan
2
5.6k
Building Serverless Ruby Bots @ Ruby Conf 2018
damirsvrtan
0
500
Building Serverless Ruby Bots @ Paris.rb Conf 2018
damirsvrtan
1
2.6k
Importing and serving millions of records
damirsvrtan
1
240
Stateless authentication w/ JSON Web Tokens
damirsvrtan
5
400
Building Ruby Bots on AWS Lambda
damirsvrtan
0
1.3k
Reinventing The Bootcamp Idea
damirsvrtan
0
300
Other Decks in Programming
See All in Programming
golang-bob.pdf
iwatsukayura
0
130
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
最近”作らせてる” ローカルAIアプリの話
akit37
0
460
Next.js: The final boss of Web Performance
guaca
0
190
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
Jetpack Compose Mechanisms
skydoves
3
800
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.4k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
250
contenteditable と日本語入力に向き合う
colorful12
0
200
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
400
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
140
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
340
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
GraphQLとの向き合い方2022年版
quramy
50
15k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
570
A Soul's Torment
seathinner
8
3.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
The Curious Case for Waylosing
cassininazir
1
570
Code Reviewing Like a Champion
maltzj
529
40k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
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.