Restful Rails 1.2

January 22, 2007 § Leave a comment

One of the coolest new features of Rails 1.2 is the RESTful routing. In
particular, the new scaffold_resource generator makes it really easy
to mockup a basic resource-oriented web app with trivial amounts
of code. Check it out.

# rails
1.2.1

# mongrel
1.0.1

$ rails
restful

$ cd
!$

$ script/generate scaffold_resource
Entry title:string content:text
published:date

# can now specify fields as
part of the generator

$ mate
config/database.yml

development:

adapter: sqlite3

dbfile:
db/restful_development.db

$ rake
db:migrate # note new syntax!

$
script/server -d

$ open
http://0.0.0.0:3000/entries/

$ curl
http://0.0.0.0:3000/entries/1.xml #automatic
formats

$ curl -I
http://0.0.0.0:3000/entries/1.xml # note Content-Type.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

What’s this?

You are currently reading Restful Rails 1.2 at iHack, therefore iBlog.

meta

%d bloggers like this: