Sha256: 2f6be2d756df30aacd5d01bee993f03c09063361878bd883d5642e78d0dd83ae

Contents?: true

Size: 1.2 KB

Versions: 36

Compression:

Stored size: 1.2 KB

Contents

# Rao::Api:ServiceController
Short description and motivation.

## Usage

### Basic example

We are going to add a REST api to a basic rails model.

Assume you have a Post model:

```ruby
# app/models/post.rb
class Post < ApplicationRecord
end
```

To add an api endpoint at /api/posts we will need routes and an api controller.

First the routes:

```ruby
# config/routes.rb
Rails.application.routes.draw do
  namespace :api do
    resources :posts
  end
end
```

Then the controller:

```ruby
# app/controllers/api/posts_controller.rb
module Api
  class PostsController < Rao::Api::ResourcesController::Base
    # Here we specify the model class this controller is for.
    def self.resource_class
      Post
    end
  end
end
```


## Installation
Add this line to your application's Gemfile:

```ruby
gem 'rao-api-resources_controller'
```

And then execute:
```bash
$ bundle
```

Or install it yourself as:
```bash
$ gem install rao-api-resources_controller
```

Generate the initializer:

```bash
$ rails g rao:api:resources_controller:install
```

## Contributing
Contribution directions go here.

## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
rao-api-resources_controller-0.0.28.pre README.md
rao-api-resources_controller-0.0.27.pre README.md
rao-api-resources_controller-0.0.26.pre README.md
rao-api-resources_controller-0.0.25.pre README.md
rao-api-resources_controller-0.0.24.pre README.md
rao-api-resources_controller-0.0.23.pre README.md
rao-api-resources_controller-0.0.22.pre README.md
rao-api-resources_controller-0.0.21.pre README.md
rao-api-resources_controller-0.0.20.pre README.md
rao-api-resources_controller-0.0.19.pre README.md
rao-api-resources_controller-0.0.18.pre README.md
rao-api-resources_controller-0.0.17.pre README.md
rao-api-resources_controller-0.0.16.pre README.md
rao-api-resources_controller-0.0.15.pre README.md
rao-api-resources_controller-0.0.14.pre README.md
rao-api-resources_controller-0.0.13.pre README.md