11# rest-api-generator
22
3- This gem helps you to build a Ruby on Rails REST API, using a scaffold generator following the best practices.
3+ This gem helps you to build a Ruby on Rails REST API faster, using a scaffold-like generator that follows the best
4+ practices.
45
56## How it works?
67
7- The gems use rails generators and some templates to create all resources needed to build an REST API.
8+ The gems use vanilla Rails generators n combination with our templates to create all the resources needed to build a
9+ REST API.
810
9- The controller is built following SwitchDreams default way:
11+ Following [ Switch Dreams's] ( https://www.switchdreams.com.br/] ) coding practices, the controllers are built with:
12+
13+ - We use an error module to centralize error handling, rescuing from a custom and some of ActiveRecord exceptions.
14+ The inspiration for this strategy was
15+ this [ article] ( https://medium.com/rails-ember-beyond/error-handling-in-rails-the-modular-way-9afcddd2fe1b. )
1016
11- - Using an error handler module to deal with a custom exception for centralize error handler following
12- this article https://medium.com/rails-ember-beyond/error-handling-in-rails-the-modular-way-9afcddd2fe1b .
1317- For tests, we use RSpec and FactoryBot.
1418
1519## Installation
@@ -32,16 +36,17 @@ Or install it yourself as:
3236
3337## Requirements
3438
35- 1 . You need to have installed in your application rspec and factory bot
39+ 1 . You need to have installed RSpec and FactoryBot in your application.
3640
3741<ul >
38- <li >Rspec : https://github.com/rspec/rspec-rails</li >
42+ <li >RSpec : https://github.com/rspec/rspec-rails</li >
3943 <li >Factory bot: https://github.com/thoughtbot/factory_bot_rails</li >
4044</ul >
4145
42462 . Include in ApplicationController the error handler module:
4347
4448``` ruby
49+
4550class ApplicationController < ActionController ::API
4651 include RestApiGenerator ::ErrorHandler
4752end
@@ -129,14 +134,8 @@ push git commits and the created tag, and push the `.gem` file to [rubygems.org]
129134
130135Bug reports and pull requests are welcome on GitHub at https://github.com/SwitchDreams/rest-api-generator . This project
131136is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
132- the [ code of conduct] ( https://github.com/SwitchDreams/rest-api-generator/blob/master /CODE_OF_CONDUCT.md ) .
137+ the [ code of conduct] ( https://github.com/SwitchDreams/rest-api-generator/blob/main /CODE_OF_CONDUCT.md ) .
133138
134139## License
135140
136141The gem is available as open source under the terms of the [ MIT License] ( https://opensource.org/licenses/MIT ) .
137-
138- ## Code of Conduct
139-
140- Everyone interacting in the Rest::Api::Generator project's codebases, issue trackers, chat rooms and mailing lists is
141- expected to follow
142- the [ code of conduct] ( https://github.com/[USERNAME]/rest-api-generator/blob/master/CODE_OF_CONDUCT.md ) .
0 commit comments