Fix Rakefile with respect to sinatra-activerecord: remove some old tasks, register Sinatra::ActiveRecordExtension, don't automatically require sinatra-contrib.
Add optimistic locking via a numeric version field.

If a client fetches a document with version 1, and then tries to post the same document (with the version 1 as part of the POST data), and another client has modified the document in the meantime, the request will fail.