Building A RESTful API in Rails 3
I just put together a short screencast showing how simple it is to build a RESTful API using Rails 3.
The screencast also shows how the default scaffold templates can be refactored to be DRYer.
You can pull a copy of the application code (with further refactoring advice) from it's repository on GitHub
Feedback and replies welcome
Filed under: Ruby on Rails, API, REST, Screencasts
This is why I love Rails!
Great presentation by the way - well done
Hi,
Thanks for the screencast. This is not exactly a REST API, it's a CRUD interface that spits JSON.
An API is RESTful if it satisfies the hypermedia constraint. You can look up HATEOAS for more information.
@ZingZong - thanks for your comment!
You're right that this screencast is only showing how to build a CRUD app that spits out JSON. I initially put the video together to show a client who's planning to build a REST API for their web service that Ruby on Rails was a good way to go.
The screencast was really to show off Rails as a tool than a step-by-step to building a REST API. I hadn't thought when posting it to the blog that this context would be lost though.
Your comment prompted me to do more research on REST and HATEOAS though. This post and the comments discussion below are a great read.
From what I (now) understand about HATEOAS, building a truly RESTful API using the JSON MIME-type would involve also responding with the URLs for permitted actions too... which in most cases I would argue is pedantic.
I love your accent - lol
Well done!
Hello, thx for screencast. Unfortunately there is a proble with show method. It is no more working for me after change. It returns:
Template is missing
Missing template categories/show, application/show with {:locale=>[:en], :formats=>[:json], :handlers=>[:erb, :builder, :coffee]}. Searched in... }
I love the speed you type at ! Bas$^$£d :)
Brilliant. This is exactly what I needed, and I didn't have to read reams of docs or sit through some hour-long tutorials. Thanks!
Thank you very much. exactly what I need