Rails Versioned API solution template for hipsters!
- Version 3.1.0
- Prerequisites
- Project Setup
- Development
- GraphQL API playground
- Tools
- Pry initializer
- Traceroute
- GraphQL Preload gem
- Test API with Postman
- For production, you need to replace the asterisk with the URL of your client-side application in ./config/initializers/cors.rb file.
- Clone or download this repo
- Run
bundle install
- Run
rake db:create
- Run
bin/rails db:migrate RAILS_ENV=development
- Run
bin/rails db:seed RAILS_ENV=development
- Run
foreman start -f Procfile.dev
- Visit --> http://localhost:5000/. That's it!.
- Open http://localhost:5000/graphiql and play with GraphQL.
- Run
rubocop
for Ruby lint. - Run
rubocop -a
for fixed some issues automatically. - Run
reek .
for analyzing code. - Run
brakeman
for static analysis and for security vulnerabilities. - Run
rails_best_practices .
in root app directory. Helps to find unused methods, missing indexes into database tables and many other things.
To annotate all your models, tests, fixtures, and factories:
cd /path/to/app
annotate
To annotate just your models, tests, and factories:
annotate --exclude fixtures
To annotate just your models:
annotate --exclude tests,fixtures,factories,serializers
To annotate routes.rb:
annotate --routes
To remove model/test/fixture/factory/serializer annotations:
annotate --delete
To remove routes.rb annotations:
annotate --routes --delete
To automatically annotate every time you run db:migrate, either run rails g annotate:install or add Annotate.load_tasks to your Rakefile
. See the configuration in Rails section for more info.
- You need configure
.gitlab-ci.yml
file with your Heroku credentials.
- You need configure
.travis.yml
file with your Travis and Heroku credentials.
Avoid repeating yourself, use pry-rails instead of copying the initializer to every rails project.
- Run
rails console
and in Rails console: - For showing models -->
show-models
. - For showing routes -->
show-routes
.
- Run
rake traceroute
.
- You can find some examples here.