Skip to content

stalniy/rails-cancan-api-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rails 5 REST API with CanCan

This is an example of API based on Rails5 and CanCan which can be integrated with CASL. Read CASL and Cancan for details

Installation

If you don't have Ruby, install it (e.g., by using rvm and when you finish, just run this:

gem install bundler
bundle install

Then configure database (it uses sqlite3 by default) in config/databse.yml and run migrations and seeds:

rails db:migrate
rails db:seed

Seeds adds 2 users:

API

To login send:

POST /api/session

{
  "email": "[email protected]", # or [email protected]
  "password": "123456"
}

The response will give back JWT token and a list of rules which can be read by CASL

Run rails routes to see the full list of routes. articles and users follows the general REST CRUD scheme.

Run Server

rails s

About

Simple Rails 5 REST API with cancan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 99.0%
  • HTML 1.0%