RESTful Product Tracker

January 19th, 2007 Rails

The RESTful Product Tracker is a simple rails application I built to help people learn Rails.

I noticed there are not many simple examples of Rails applications out there to help a new Railer learn the ropes. I know I always learn best by tearing apart some real code.

In particular this app should help introduce you to some RESTful techniques offered by Rails 1.2.

Enjoy!

Home page

Home page

Company view

Company view

Edit company

Edit company

Products listing

Products listing

Product view

Product view

Get the code

> svn co http://svn.depixelate.com/applications/restful_product_tracker
> cd restful_product_tracker

Freeze to Rails 1.2.1 (optional)

If you don't have Rails 1.2.1 then freeze it!

> rake rails:freeze:edge TAG=rel_1-2-1

Setup databases

> mysql
mysql> create database product_tracker_development;
mysql> create database product_tracker_test;
mysql> exit;

Run migrations

> rake db:migrate
> rake db:migrate RAILS_ENV=test

Load fixtures for some sample data

> rake db:fixtures:load

Start the server

> ./script/server

Open a browser

Go to http://localhost:3000/companies

--- --- ---

8 Comments

  1. Comment by Peter Dunton on 01/19/07

    I was hoping that you would explain the code a bit rather then just the deployment steps. Will you do that in another post.

    Thanks again for sharing the code though!

  2. Comment by Zack Chandler on 01/19/07

    Peter - Is there anything in particular that you'd like explanation on? I've always found that I learn well by picking apart code from a live example. That was the idea I had with putting this sample app together.

  3. Comment by GenĂ­s on 01/20/07

    Thanks for sharing this code. Sure it will help me to undestand better REST in Rails.

  4. Comment by Jim Morris on 01/21/07

    Thanks, very instructive. If you were to add explanations, I would start by explaining what is RESTful about this code vs regular CRUD, what RESTful design decisions you made, explain the routing and how it is RESTful. For instance I still get confused by the link_to syntax used in REST :)

  5. Comment by Sandro Paganotti on 01/31/07

    This is the first time i can download a REAL RESTful application !! Thank you very much!

  6. Comment by Bill Berry on 02/08/07

    This was helpful. I noticed the controllers are set up to handle rss and xml. Can you comment on the proper URLs to access that stuff? Thanks.

  7. Comment by Zack on 02/08/07

    Bill,

    Just tack on the supported format to the base url.

    XML

    http://localhost:3000/companies.xml

    http://localhost:3000/companies/1.xml

    http://localhost:3000/companies/1/products/5.xml

    RSS

    http://localhost:3000/companies.rss

    Hope this helps - feel free to ask more questions and give feedback.

  8. Comment by Bill Berry on 02/08/07

    Thanks, Zack. Just what I needed!

Commenting is closed for this article.