Building an RoR API app that cover the following:
- User
- Registration
- Authentification
- Email confirmation
- Recover account
- Article
- Create
- View one article + comments
- View articles
- Edit
- Delete
- Comments
- Create
- View
- Categories
- View all
Pumaas the web serverPostgreSQLas the primary database and for Full Text SearchRedisto store cached dataSidekiqfor background workers
Note: MacOS ships with a version of Ruby, needed for various operating systems. To avoid causing an issue with your operating system you should use a version manager for Ruby.
If you don't already have a Ruby version manager, we highly recommend rbenv. This will allow you to have different versions running on a per project basis. The MacOS system version of Ruby will stay intact while giving you the ability to use the version needed for this Forem project. Please follow their installation guide.
- With the Ruby version manager, install the Ruby version listed on our badge.
(i.e. with rbenv:
rbenv install $(cat .ruby-version))
brew install postgresbrew install redisThe next step is to load the data
rails db:create db:migrateDone, now you should be able to see the app on localhost:3000
rails serverStep 1. Install docker and docker-compose
Step 2. Run the below command
docker-compose up -d && docker-compose ps && docker-compose exec app bundle exec rake db:setup Note: This will install all the dependencies, run the docker-compose, create a database, seed the database.
Sample output
1. Creating Users.
Admin User created
Other User created 9999
2. Creating Categories.
Category Created 3
3. Creating Articles.
Article created 10000
4. Creating Tags.
Tags created 5Step 3. Check the logs
docker-compose logsIf you have reached hear, voila. you have done it.
Enjoy the API!!!
Below is the API collection reference link, refer it and enjoy the API.
Postman collection documentation
At any point in time, you wish to stop the execution and inspect the code run.
Step 1: Put byebug in the function/code area.
Step 2: Attach your terminal to the container
docker attach <container_id>You may find your container_id by using: docker container ls
At this point, you should be able to see every input, output, and error from our running container.
You can always detach from this Docker process by entering the escape sequence: Ctrl+P then Ctrl+Q
Step 3: If you wish to access rails console or rails db from the terminal
docker-compose exec app rails console/db