No description or website provided.
Ruby JavaScript CoffeeScript eC Shell Lua
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app
config
doc
lib
log
public
rack-proxy/ruby/1.9.1
script
spec/javascripts
test
vendor
.gitignore
Gemfile
Gemfile.lock
LICENSE.markdown
README.markdown
Rakefile
config.ru

README.markdown

RESTful Clients in Rails - the Demo

This is the sample code for the "RESTful Clients in Rails" talk by Jack Lawson (ajacksified).

Tested with Ruby 1.9.3. Uses Rails 3.2.1.

Setup Notes

Note the configuration in config/initializers/hogan_assets and config/initializers/stache. These need to match each other so that they can point to each other's mustache views for client delivery and rendering.

Optionally, if you just want to check out the mustache / backbone / rails stuff and not the API, stub out the two calls to api_call in offers_controller and return formatted JSON (as defined in the next section.)

Endpoint Notes

API endpoint not included. Copy the api_endpoints.yml.example file, whack the .example from the end, and point at a local server that serves up super simple JSON with a format such as the following:

{
  "response_data": {
    "id":7,
    "start_date":"2010-05-28",
    "end_date":"2010-06-01",
    "title":"50% Off Round Pond Estate Wine Tasting and Gourmet Gift Box ",
    "sales_pitch":"<p>Let&rsquo;s face it. Of all the ways to get through the week, &nbsp;there&rsquo;s one that sticks out above the rest: Wine. So how about taking that to&nbsp;the next level with a special trip to Round Pond Estate in the highly acclaimed&nbsp;Rutherford region of Napa Valley? There, you will get a Round Pond Wine Tasting&nbsp;for two, paired with delectable gourmet appetizers made with ingredients farmed right on the estate itself. &nbsp;The tasting includes the 2007 Cabernet Sauvignon that just scored 94 points with Wine Spectator.</p>\r\n<p>The experience doesn't end once you leave the estate. You&rsquo;ll also get the Round Pond Gourmet Classic&nbsp;Gift Box, with a variety of treats including a bottle of their award winning olive oil, their syrup, their vinegar and last but certainly not least, a bottle of their 2006 Cabernet Sauvignon.&nbsp;</p>"
  }
}

Or, better yet, play with this code, modify it to hit some other open API like Twitter and build something.

Todo

  • Rewrite application controller api call method, which is really hacky.

License

All code MIT licensed.