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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
500
Crossing Domain Boundaries with GraphQL
damirsvrtan
0
180
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
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
200
AIプロダクト時代のQAエンジニアに求められること
imtnd
1
490
AHC061解説
shun_pi
0
230
DevinとClaude Code、SREの現場で使い倒してみた件
karia
0
210
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1.1k
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
130
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
190
CSC307 Lecture 14
javiergs
PRO
0
440
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
320
ご飯食べながらエージェントが開発できる。そう、Agentic Engineeringならね。
yokomachi
1
270
AI活用のコスパを最大化する方法
ochtum
0
110
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
2k
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1032
470k
The agentic SEO stack - context over prompts
schlessera
0
670
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Making Projects Easy
brettharned
120
6.6k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
210
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Visualization
eitanlees
150
17k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
130
Docker and Python
trallard
47
3.7k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
59
50k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
130
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.