Backend for the second homework.
Note: Tested on both OS X and Linux (Wheezy 64b).
$ \curl -L https://get.rvm.io | bash -s stable
$ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
$ rvm install 1.9.3 && rvm use 1.9.3 && rvm --default use 1.9.3
$ gem install rails
$ rails new test.rails
$ cd test.rails
Uncomment this line # gem 'therubyracer', :platforms => :ruby in the Gemfile file.
$ bundle install
$ rails server
Nagivate in browser to: http://localhost:3000 and you should see welcome aboard page.
- clone to you computer
- cd into folder
- type
rake db:create - type
rake db:migrate - type
$ rails server - verify at
http://localhost:3000/items - profit!
Array of items.
[
{
"id":1,
"created_at":"2012-10-24T14:03:27Z",
"title":"First Entry",
"subtitle":"\u2026totally awesome",
"price":"9.99",
"available":"2012-10-30"
},
{
"id":3,
"created_at":"2012-10-24T14:13:30Z",
"title":"yahooo",
"subtitle":"dobry den",
"price":"6.5",
"available":null
}
]
Detailed info of an item.
{
"available":"2012-10-30",
"created_at":"2012-10-24T14:03:27Z",
"description":"Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"id":1,
"imageurl":"http://illy.kubbing.com/t-ar/1.gif",
"price":"9.99",
"subtitle":"\u2026totally awesome",
"title":"First Entry",
"updated_at":"2012-10-24T14:03:43Z"
}
Creates new item at the server.
{
"item[available]":"2012-10-30",
"item[description]":"Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"item[imageurl]":"http://illy.kubbing.com/t-ar/1.gif",
"item[price]":"9.99",
"item[subtitle]":"\u2026totally awesome",
"item[title]":"First Entry",
}
{
available = "<null>";
"created_at" = "2012-10-24T22:55:19Z";
description = "<null>";
id = 33;
imageurl = "<null>";
price = "3.1415";
subtitle = "<null>";
title = "2012-10-24 22:55:16 +0000";
"updated_at" = "2012-10-24T22:55:19Z";
}
Updates an item at the server.
{
"item[available]":"2012-10-30",
"item[description]":"Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"item[imageurl]":"http://illy.kubbing.com/t-ar/1.gif",
"item[price]":"9.99",
"item[subtitle]":"\u2026totally awesome",
"item[title]":"First Entry"
}
Deletes an item at the server.