To adapt Rails better

Hi Bodgan, I used this your library for several months. But I sent this pull request late. I work on Rails apps, thus my changes are related to working with Rails better and easier.

* Line 15: I forgot why I changed line 15, but it seems working fine with my Rails App.
* Line 106: Easier for Rails to send back error message response using `format.json`.

For example:

```ruby
format.json do
  if correct
    render json: { redirect: root_path }
  else
    render json: { errors: @errors }
  end
end
```