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
Rails API
Search
Saurabh Bhatia
February 22, 2014
Technology
0
430
Rails API
API only applications with Rails API
Saurabh Bhatia
February 22, 2014
Tweet
Share
More Decks by Saurabh Bhatia
See All by Saurabh Bhatia
Barrister RPC
thewub
0
450
RulingOrbit
thewub
0
380
Symbols and Hashes Intro
thewub
0
55
Cloud Primer
thewub
1
410
Other Decks in Technology
See All in Technology
ビズリーチにおけるリアーキテクティング実践事例 / JJUG CCC 2025 Spring
visional_engineering_and_design
1
120
AWS Organizations 新機能!マルチパーティ承認の紹介
yhana
1
280
敢えて生成AIを使わないマネジメント業務
kzkmaeda
2
440
生成AI時代の開発組織・技術・プロセス 〜 ログラスの挑戦と考察 〜
itohiro73
1
460
KubeCon + CloudNativeCon Japan 2025 Recap Opening & Choose Your Own Adventureシリーズまとめ
mmmatsuda
0
270
Beyond Kaniko: Navigating Unprivileged Container Image Creation
f30
0
130
CRE Camp #1 エンジニアリングを民主化するCREチームでありたい話
mntsq
1
120
ネットワーク保護はどう変わるのか?re:Inforce 2025最新アップデート解説
tokushun
0
210
Claude Code に プロジェクト管理やらせたみた
unson
6
4k
United airlines®️ USA Contact Numbers: Complete 2025 Support Guide
unitedflyhelp
0
310
FOSS4G 2025 KANSAI QGISで点群データをいろいろしてみた
kou_kita
0
400
AI時代の開発生産性を加速させるアーキテクチャ設計
plaidtech
PRO
3
150
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
The Invisible Side of Design
smashingmag
301
51k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.9k
Navigating Team Friction
lara
187
15k
Writing Fast Ruby
sferik
628
62k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
How GitHub (no longer) Works
holman
314
140k
Bash Introduction
62gerente
613
210k
Transcript
API Only Applications with rails-api Saurabh Bhatia http://fedible.org
what? $ gem install rails-api Rails minus some middleware stack,
actionpack modules and template generation.
why? • Lightweight • Fast • API only application –
backend for mobile app, web application is just another client (e.g. html, angular.js ) to a json api.
Generating a new app $ rails-api new notesapp
No views
rails-api controller app/controllers/application_controller.rb class ApplicationController < ActionController::API end
controller actions def index @posts = Post.all render json: @posts
end • rails-api uses render instead of respond methods. • Let's see how to include those.
extending controller class ApplicationController < ActionController::API include ActionController::MimeResponds include ActionController::ImplicitRender
end • MimeResponds and Implicit render provide support for respond_to, respond_with.
middleware
extending middleware $config/application.rb require File.expand_path('../boot', __FILE__) require 'rails/all'. Bundler.require(:default, Rails.env)
module Notesapp class Application < Rails::Application config.middleware.use ActionDispatch::Flash end end
extended
serializers • gem "active_model_serializers" • $rails g serialzer post •
$ ls assets controllers mailers models serializers app$ cd serializers/ app/serializers$ ls post_serializer.rb
serialzers class PostSerializer < ActiveModel::Serializer attributes :title, :body end •
JSON Response {"posts": [{"id":1,"title":"First Post","body":"Test"}, {"id":2,"title":"Second Post","body":"Another Test"}] }
Shameless Plug : Rails 4 application development
Thank you 謝謝