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
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
200
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
370
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
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
570
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.4k
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
Oxlintのカスタムルールの現況
syumai
6
1.1k
Oxcを導入して開発体験が向上した話
yug1224
4
340
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.5k
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
13
6.2k
AIで効率化できた業務・日常
ochtum
0
140
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
Lessons from Spec-Driven Development
simas
PRO
0
220
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
1
150
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
310
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
ラッコキーワード サービス紹介資料
rakko
1
3.7M
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
210
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
The browser strikes back
jonoalderson
0
1.3k
Visualization
eitanlees
152
17k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
sira's awesome portfolio website redesign presentation
elsirapls
0
280
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.