Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Responders
Search
DamirSvrtan
September 14, 2015
Programming
0
58
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
490
Crossing Domain Boundaries with GraphQL
damirsvrtan
0
170
Surrounded by Microservices
damirsvrtan
2
5.4k
Building Serverless Ruby Bots @ Ruby Conf 2018
damirsvrtan
0
450
Building Serverless Ruby Bots @ Paris.rb Conf 2018
damirsvrtan
1
2.4k
Importing and serving millions of records
damirsvrtan
1
190
Stateless authentication w/ JSON Web Tokens
damirsvrtan
5
340
Building Ruby Bots on AWS Lambda
damirsvrtan
0
1.2k
Reinventing The Bootcamp Idea
damirsvrtan
0
230
Other Decks in Programming
See All in Programming
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.4k
認証・認可の基本を学ぼう後編
kouyuume
0
250
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
8
3.4k
GoLab2025 Recap
kuro_kurorrr
0
780
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
980
Python札幌 LT資料
t3tra
7
1.1k
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
650
Basic Architectures
denyspoltorak
0
120
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
390
TestingOsaka6_Ozono
o3
0
180
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
160
Cap'n Webについて
yusukebe
0
150
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
680
Building Applications with DynamoDB
mza
96
6.8k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
230
4 Signs Your Business is Dying
shpigford
186
22k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
170
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Heart Work Chapter 1 - Part 1
lfama
PRO
3
35k
ラッコキーワード サービス紹介資料
rakko
0
1.8M
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
100
GitHub's CSS Performance
jonrohan
1032
470k
The Cost Of JavaScript in 2023
addyosmani
55
9.4k
The browser strikes back
jonoalderson
0
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.