Upgraded from Rails 3.2.8 to Rails 4 (First attempt)

* Updated project dependencies in Gemfile.
* Updated some project's configs.
* Updated routings (mainly for fixing the usage of 'match').
* Removed Devise's config file from source control, since it will
contain secret key. This file needs to be generated in project's
setup.
* Replace '&' and '^' with '\z' and '\A' on active record
validation.
* Added missing 'render_404' method in 'restful_controller'.
* Open uploaded file in binary mode.
* Updated the generated db migration script.
* Fixed a bug that tried to join an empty backtrace.