For testing I recommend using Postman :)
- Clone the repo
git clone https://github.com/CMarzin/rails-api-with-token-generator.git
- Install dependency
bundle install
- Run migration and seed
rails db:migrate && rails db:seed
- Run the server
rails s
Working on production env ( Heroku )
I assume you already have the Heroku CLI installed
Rails 5 disables autoloading in production.
The three options are:
- Move lib/json_web_token.rb into app/lib/ so rails loads it automatically
- Use eager loading instead of autoloading: config.eager_load_paths << Rails.root.join('lib')
- Force rails to allow autoloading: config.enable_dependency_loading = true
I choose to do the first option
Thanks to Kevin Holler who discovered the issue.
- Create an app heroku
- Add the heroku remote
heroku git:remote -a the-name-of-your-app
- Push to heroku
git push heroku master
That's it :)
This repo is made after use these two tutorial :