wiki:Examples/ServeItUp

Serve It Up

Before we can do any fancy stuff with jactiveresource we need a rails service to access.

For Rails 2.3

First we create a new rails application:

$ rails servicetest

Then generate a new Person resource. We are using the scaffolding generator instead of the resource generator to make things move along quicker.

$ cd servicetest
$ script/generate scaffold person name:string birthdate:datetime

Until ticket:11 is closed, you have to add the following line to your rails controllers for jactiveresource to be able to consume them:

class PeopleController < ApplicationController
  skip_before_filter :verify_authenticity_token
...

Migrate the database to create our new people table:

$ rake db:migrate

Now, fire up rails:

$ script/server

You now have a working people service at  http://localhost:3000/people

For Rails 3.0

First we create a new rails application:

$ rails servicetest

Then generate a new Person resource. We are using the scaffolding generator instead of the resource generator to make things move along quicker.

$ cd servicetest
$ rails generate scaffold person name:string birthdate:datetime

Migrate the database to create our new people table:

$ rake db:migrate

Now, fire up rails:

$ rails server

You now have a working people service at  http://localhost:3000/people