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
![]()
Company view
![]()
Edit company
![]()
Products listing
![]()
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
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!
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.
Thanks for sharing this code. Sure it will help me to undestand better REST in Rails.
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 :)
This is the first time i can download a REAL RESTful application !! Thank you very much!
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.
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.
Thanks, Zack. Just what I needed!
Commenting is closed for this article.