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.48.pre README.md
rao-api-resources_controller-0.0.47.pre README.md
rao-api-resources_controller-0.0.46.pre README.md
rao-api-resources_controller-0.0.45.pre README.md
rao-api-resources_controller-0.0.44.pre README.md
rao-api-resources_controller-0.0.43.pre README.md
rao-api-resources_controller-0.0.42.pre README.md
rao-api-resources_controller-0.0.41.pre README.md
rao-api-resources_controller-0.0.40.pre README.md
rao-api-resources_controller-0.0.39.pre README.md
rao-api-resources_controller-0.0.38.pre README.md
rao-api-resources_controller-0.0.37.pre README.md
rao-api-resources_controller-0.0.36.pre README.md
rao-api-resources_controller-0.0.35.pre README.md
rao-api-resources_controller-0.0.34.pre README.md
rao-api-resources_controller-0.0.33.pre README.md
rao-api-resources_controller-0.0.32.pre README.md
rao-api-resources_controller-0.0.31.pre README.md
rao-api-resources_controller-0.0.30.pre README.md
rao-api-resources_controller-0.0.29.pre README.md