I\'m a Rails and REST newbie and I\'m trying to figure how best to expose a resource that is backed by a domain object that has a state machine (in other words is a finite a
If your resource has some kind of status attribute, you can use a technique called micro-PUT to update it's status.
PUT /Customer/1/Status
Content-Type: text/plain
Closed
=> 200 OK
Content-Location: /Customer/1
You can model resource states as collections and move resources between those collections.
GET /Customer/1
=>
Content-Type: application/vnd.acme.customer+xml
200 OK
POST /ClosedCustomers
Content-Type: application/vnd.acme.customer+xml
=>
200 OK
POST /OpenCustomers
Content-Type: application/vnd.acme.customer+xml
=>
200 OK
You could always use the new PATCH method
PATCH /Customer/1
Content-Type: application/x-www-form-urlencoded
Status=Closed
=>
200 OK