https://github.com/teohm/event-api
a rails3 example app that demonstrates how to use RABL gem
https://github.com/teohm/event-api
Last synced: over 1 year ago
JSON representation
a rails3 example app that demonstrates how to use RABL gem
- Host: GitHub
- URL: https://github.com/teohm/event-api
- Owner: teohm
- Created: 2011-09-21T05:27:33.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2011-09-21T06:54:51.000Z (almost 15 years ago)
- Last Synced: 2025-02-05T04:49:18.227Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 121 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RABL - an intro
## fork me
git clone https://github.com/teohm/event-api
## problem?
When building a non-trivial web API, you may notice it is
difficult use `to_json` or `as_json` to serialize model into JSON:
http://engineering.gomiso.com/2011/05/16/if-youre-using-to_json-youre-doing-it-wrong/
## rabl - ruby api builder language
RABL provides a simple DSL to generate JSON/XML from model.
See https://github.com/nesquena/rabl
## demo - event management app
3 models: User, Event, EventGuest
# To load sample data
bundle exec rake db:migrate:reset
bundle exec rake db:fixtures:load
### 1. use `extends` to reuse
- http://localhost:3000/users/1
- http://localhost:3000/users
### 2. use `child` to add more fields
- http://localhost:3000/events
### 3. use `glue` to attach child fields directly to parent
- http://localhost:3000/events/1/guests