README.md in rails_api_response-1.1.0 vs README.md in rails_api_response-1.2.0
- old
+ new
@@ -1,11 +1,9 @@
# RailsApiResponse
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails_api_response`. To experiment with that code, run `bin/console` for an interactive prompt.
-TODO: Delete this and the text above, and describe your gem
-
## Installation
Add this line to your application's Gemfile:
```rails
@@ -20,10 +18,18 @@
$ gem install rails_api_response
## Usage
-TODO: Write usage instructions here
+Add the line `include RailsApiResponse::ControllerHelpers::Responses` to the controller where you want to you response format. (Recommended: base or application controller).
+
+Response success: `respond_success message: "Create user successfully", data: {}`.
+
+Response error: `respond_error message: "Create user failed", data: {}` or `respond_error instance: @user, data: {}` (with instance param, the format will be got from errors and full message from instance.
+
+Response with customer code: `respond_json code: 200, message: "", data: {}`.
+
+The last format will be always `{ code: 200, metadata: { message: '' }, data: {} }`
## Development
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.