Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rails API
Search
Saurabh Bhatia
February 22, 2014
Technology
460
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
68
Cloud Primer
thewub
1
420
Other Decks in Technology
See All in Technology
ハードウェアコンペでもAI駆動開発が進んでいる話
iotengineer22
1
690
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
320
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
880
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
0
230
分析AIエージェントを育てる、動く環境を育てる
codatum
1
1k
freeeらしさをAIとともに作る / Creating the freee Experience with AI
ymrl
0
230
Classmethod Company Deck
satoshi7
0
130
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.7k
Snapshot Testing in Practice: Predictable and Reliable SwiftUI Views
fespinoza
0
200
ゲームのリアルタイム通信から見た QUIC と MoQ
segadevtech
0
110
継続的なAIコスト最適化
bgpat
1
290
事業活動を AI Ready にする攻めと守りのデータエンジニアリング / data-engineering-for-ai-ready-business
pei0804
7
2.6k
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
520
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
Statistics for Hackers
jakevdp
799
230k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
980
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
470
Leo the Paperboy
mayatellez
10
2.4k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
430
So, you think you're a good person
axbom
PRO
2
2.2k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Believing is Seeing
oripsolob
1
240
Faster Mobile Websites
deanohume
310
32k
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 謝謝