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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Saurabh Bhatia
February 22, 2014
Technology
450
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails API
API only applications with Rails API
Saurabh Bhatia
February 22, 2014
More Decks by Saurabh Bhatia
See All by Saurabh Bhatia
Barrister RPC
thewub
0
470
RulingOrbit
thewub
0
390
Symbols and Hashes Intro
thewub
0
66
Cloud Primer
thewub
1
420
Other Decks in Technology
See All in Technology
内製AIチャットボット開発で学んだ Datadog Agent Observability活用術
mkdev10
0
130
tamachi.go 誕生の裏側
rymiyamoto
1
200
AI時代のデータ基盤を考える問い
pacocat
0
460
小粒でもパワフルなJS Runtime Antjsについて
comamoca
0
120
Sets in Go
ramalho
1
1.2k
強化学習「理論」入門
enakai00
3
3.6k
【Aiming】共通基盤なのに「共通化しない」課金・認証基盤「LINK」が選び取ったシングルテナント戦略と運用の秘訣
saikeda
0
180
わたしが知り合いゼロの勉強会に 行けるようになるまで
r5ni4
2
430
LLM Internals: 언어 모델의 계보와 알고리즘 진화 (2023~2026)
inureyes
PRO
1
900
国家プロジェクトを支える「さくらONE」 大規模LLM開発におけるGPU障害を乗り越えるクラスター運用戦略
gpuunite_official
0
270
:syncing_time:
sksat
2
660
AIで変わるエンジニアの働き方(仮)
naoinaoi
0
490
Featured
See All Featured
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
290
Product Roadmaps are Hard
iamctodd
55
12k
A Modern Web Designer's Workflow
chriscoyier
698
190k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
480
How to Think Like a Performance Engineer
csswizardry
28
2.7k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
440
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
470
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
210
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
870
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
470
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
YesSQL, Process and Tooling at Scale
rocio
174
15k
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 謝謝