File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ The controller is built following SwitchDreams default way:
1717Add this line to your application's Gemfile:
1818
1919``` ruby
20- gem ' rest-api-generator'
20+ group :development do
21+ gem ' rest-api-generator'
22+ end
2123```
2224
2325And then execute:
@@ -30,13 +32,25 @@ Or install it yourself as:
3032
3133## Requirements
3234
33- You need to have installed in your application rspec and factory bot
35+ 1 . You need to have installed in your application rspec and factory bot
3436
3537<ul >
3638 <li >Rspec: https://github.com/rspec/rspec-rails</li >
3739 <li >Factory bot: https://github.com/thoughtbot/factory_bot_rails</li >
3840</ul >
3941
42+ 2 . Include in ApplicationController the error handler module:
43+
44+ ``` ruby
45+ class ApplicationController < ActionController ::API
46+ include RestApiGenerator ::ErrorHandler
47+ end
48+ ```
49+
50+ This error handler will rescue from: ` ActiveRecord::RecordNotFound `
51+ , ` ActiveRecord::ActiveRecordError ` , ` ActiveRecord::RecordInvalid ` , ` ActiveModel::ValidationError `
52+ , ` RestApiGenerator::CustomError ` .
53+
4054## Usage
4155
4256### Generate Resource
You can’t perform that action at this time.
0 commit comments