aptible/aptible-resource — pull request #3 by fancyremarker (2014-04-21 21:48:48+00:00)
Title: Add Errors model and populate on all create/update methods

cc: @sandersonet (I'll merge, but keeping you posted on all these)

This modifies the existing `Aptible::Resource` helpers to behave even more like `ActiveRecord` models:

* It adds "bang methods" for `Resource.create`, `Resource#update`, and `Resource#create_relation`
* It populates `Resource#errors` a la `ActiveRecord`, so that the first block below can be replaced with the second, avoiding code littered with `rescue` blocks.

```ruby
@user = current_aptible_user
begin
@user.update(params.slice(:ssh_public_key))
flash[:success] = 'SSH public key updated.'
rescue => e
flash[:warning] = e.body['message']
end
```

```ruby
@user = current_aptible_user
if @user.update(params.slice(:ssh_public_key))
flash[:success] = 'SSH public key updated.'
else
flash[:warning] = e.body['message']
end
```