Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Demo for using Shared Workforce in a Ruby on Rails app

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 db
Octocat-spinner-32 doc
Octocat-spinner-32 lib
Octocat-spinner-32 log
Octocat-spinner-32 public
Octocat-spinner-32 script
Octocat-spinner-32 test
Octocat-spinner-32 vendor
Octocat-spinner-32 .env_template
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 Procfile
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 config.ru
README.markdown

Shared Workforce Demo

This is an example Rails app that shows how to tag a photo using Shared Workforce.

The app has a user model which includes a photo. When a cat is created, the image is sent to Shared Workforce where it is tagged, rotated and cropped by a human worker.

You can view a live sandbox demo of the app at http://catsify.herokuapp.com

The task classes are in app/tasks, and there are associated example unit tests in test/tasks

Installation

Clone the app to your local workstation:

  $ git clone git://github.com/sharedworkforce/sharedworkforce-demo-rails.git
  Cloning into sharedworkforce-demo-rails...

Run bundle install to install required gems:

  $ cd sharedworkforce-demo-rails
  $ bundle install
  Your bundle is complete!

Setup the database:

  $ rake db:setup
  -- create_table("users", {:force=>true})
    -> 0.0042s
  -- initialize_schema_migrations_table()
    -> 0.0040s
  -- assume_migrated_upto_version(20120327110249)
    -> 0.0056s

Running the demo app

If you are using Heroku, you can use the Shared Workforce addon:

Create an app:

  $ heroku create --stack cedar
  Creating ratchet-screwdriver-trees-4005... done, stack is cedar

Add the Shared Workforce addon:

  $ heroku addons:add sharedworkforce
  -----> Adding sharedworkforce to ratchet-screwdriver-trees-4005... done, v18 (free)

Get your API key from the app's config:

  $ heroku config | grep SHAREDWORKFORCE_API_KEY
  SHAREDWORKFORCE_API_KEY => acdc30b2-14c5-46ee-ba35-11d50edc65ec

Note: If you are not using Heroku and you would like to try Shared Workforce, visit http://www.sharedworkforce.com or email erica@sharedworkforce.com.

Once you have your API key, rename the file .env_template to .env, and add your Shared Workforce API key.

  $ cp .env_template .env
  $ $EDITOR .env

Insert your key:

SHAREDWORKFORCE_API_KEY=my-api-key

Once you have entered your API key, start the app.

  $ rails s

Open the app at http://localhost:3000

There is a rake task to collect the task responses during development.

  $ rake sw:collect

Note: the rake task isn't needed in production, the webhook will take care of it.

Creating a cat

Visit http://localhost:3000 and follow the link to create a cat with an image url. Once the cat is saved, it will be sent to Shared Workforce for moderation. Typically it will take anything from a couple of minutes to an hour for your task to be completed.

Deploying to Heroku

To deploy the app on Heroku, simply deploy in the normal way.

  $ git push heroku master
  $ heroku run rake db:migrate
  $ heroku restart
  $ heroku open
Something went wrong with that request. Please try again.