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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
Agent Skills設計で柔軟性と硬さのバランスが難しい話
nassy20
0
120
自宅LLMの話
jacopen
1
370
やさしいA2A入門
minorun365
PRO
12
1.7k
白金鉱業Meetup_Vol.24_「AIエージェントは分けるほど良い」は本当か? / Is it true that “the more you divide AI agents, the better”?
brainpadpr
1
310
Microsoft Build Keynoteふりかえり
tomokusaba
0
120
2026TECHFRESH畢業分享會 - 葬送的通靈師:化系統與用戶雜訊成行動訊號
line_developers_tw
PRO
0
830
DevOps Agentで始めるAWS運用 〜フロンティアエージェントが変える運用の現場〜
nyankotaro
1
380
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
130
データサイエンスを価値につなげるプロジェクト設計 〜 DS一年目が現場で得た気づき 〜
ysd113
1
190
On-behalf-of Token exchange with AgentCore Identity
hironobuiga
2
150
AmazonRoute 53ではじめてのドメイン取得!HTTPS化までの道のりを整理してみた
usanchuu
3
130
How Timee Delivers Day 1 Production Ready LLM Features
tomoyks
0
140
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
240
Statistics for Hackers
jakevdp
799
230k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Accessibility Awareness
sabderemane
1
140
The SEO Collaboration Effect
kristinabergwall1
1
480
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
570
The untapped power of vector embeddings
frankvandijk
2
1.8k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
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 謝謝