api
This is the core api for the leo-health services.
RVM
If you are on an previous version of Ruby, be sure to run rvm upgrade 2.2.0 2.2.2
Ensure that version 2.2.2 is selected as current (and default) using rvm list
Conventions
- Using Devise gem for authentication
- Using cancancan gem for authorization
- One user model for all users, with associated models for role-specific details
- Using 'grape' to model the core API calls
- Using 'grape-entity' to serialize the models for the API responses
- Using 'rspec_api_documentation' to produce API documentation
Project Structure
- The models are in app/models
- The api is defined in app/api
- The entities are also in app/api
- The tests for the api are in spec/requests
Testing
- The tests live at spec/[models, requests, etc]
- To run the test suite,
2a. First run
rake db:test:prepare
on the command line
2b. Then run rspec spec
Setting Up
- Prerequisites: rvm, git, rails (via rvm), postgres
- Clone repository from git
- Make sure redis is running, run
redis-server
- Run
rake db:setup
to prepare and populate the database with seed data (roles, etc.).
- Run
rails s
to start the local server
Troubleshooting
- If you're getting a
HINT: Must be superuser to create this extension.
error, you need to change your postgres user priveleges. Log into postgres and run these commands: postgres=# \du #
to list all users, and then postgres=# ALTER ROLE user CREATEROLE SUPERUSER;``ALTER ROLE #
to assign user the correct priveleges.