Changed gem dependency order

Fixes Issue #586. I have changed the gem dependency order and updated the rails version number adding the fix for the latest security bug. There seems to be a issue with bundler so I had to do some tricking around to get the bundle update to work.