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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
460
RulingOrbit
thewub
0
390
Symbols and Hashes Intro
thewub
0
65
Cloud Primer
thewub
1
420
Other Decks in Technology
See All in Technology
GitHub Copilot運用のリアル ~AI Credit時代にどう向き合うか~
takafumisu2uk1
0
590
MySQL & MySQL HeatWave Report - June 2026
freshdaz
0
260
徹底討論!ECS vs EKS!
daitak
3
1.8k
5分でわかる Amazon Connect_20260608
hwangbyeonghun
0
150
IaC コードを資産へ:AWS CDK 社内ライブラリと横断展開 / aws-summit-japan-2026
gotok365
10
1.7k
NDIAS CTF 2026 問題解説会資料
bata_24
0
160
組織における AI-DLC 実践
askul
0
250
水を運ぶ人としてのリーダーシップ
izumii19
4
1.2k
スタートアップにおけるアジャイルの実践について #shibuyagile
murabayashi
3
1.7k
ご挨拶「10周年を迎える共創ラボのこれまでとこれから」
iotcomjpadmin
0
170
AWS Summit の片隅で、体育座りしながらコミュニティがにぎわう理由を考えた
k_adachi_01
2
330
40代で“やっとエンジニアになれた”――閉じた学びを開き、空の青さを知る / 20260628 Naoki Takahashi
shift_evolve
PRO
4
1.5k
Featured
See All Featured
Ruling the World: When Life Gets Gamed
codingconduct
0
270
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
The agentic SEO stack - context over prompts
schlessera
0
830
The World Runs on Bad Software
bkeepers
PRO
72
12k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
760
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
370
Git: the NoSQL Database
bkeepers
PRO
432
67k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
210
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
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 謝謝