Skip to content

Instantly share code, notes, and snippets.

@benaskins
Created July 18, 2013 04:52
Show Gist options
  • Save benaskins/6026794 to your computer and use it in GitHub Desktop.
Save benaskins/6026794 to your computer and use it in GitHub Desktop.
Desired roar behaviour
{
"departs_on":"2013-07-12",
"returns_on":"2013-07-19",
"_links": {
"self": {
"href": "http://localhost:3000/quotes/1"
}
}
}
{
"quote": {
"departs_on":"2013-07-12",
"returns_on":"2013-07-19",
"_links": {
"self": {
"href": "http://localhost:3000/quotes/1"
}
}
}
}
class QuoteRepresenter < Roar::Decorator
include Roar::Representer::JSON::HAL
property :departs_on
property :returns_on
def url
quote_url(represented, :host => 'http://localhost:3000')
end
link :self do
url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment