This API is intended to help people doing the frontend
challenge. It creates a simple database with enough endpoints to do every required task.
This API offers you 2 models that you can use in your application. Every field is updatable (except the timestamps generated by the server) via a PUT request to the API.
String name (required)
String email (required)
String job_title (required)
Date admission_date (required)
String photo_url (required)
Timestamp created_at (generated by the server)
Timestamp updated_at (generated by the server)
Int user_id (required, foreign_key)
String value (required)
Timestamp created_at (generated by the server)
Timestamp updated_at (generated by the server)
The user_id
field points to an existing user in which the comment was made.
If you don't want to use the API hosted on heroku, you can run it by yourself:
- Install RVM (
\curl -sSL https://get.rvm.io | bash -s stable
) - cd to the QultureApp folder, RVM will install the right Ruby version automatic
- Install gem bundler (
gem install bundler
, in the QultureApp folder) - Run bundler (
bundle install
)
- There might be an issue with pg, to correct that run
sudo apt-get install libpq-dev
andbundle install
again)
- Install Postgrsql-10.1, if there is some problems:
- Install Postgrsql 10.1
- Run
/etc/init.d/postgresql stop
to ensure that you don't have postgresql running at the moment - Run
sudo apt-get update
- Run
sudo apt-get install postgresql-10.1
- Run
sudo apt-get upgrade
- Install RVM (
\curl -sSL https://get.rvm.io | bash -s stable
) - Run rvm scripts (
source /Users/{YOUR_USER_HERE}/.rvm/scripts/rvm
)
- In my case
source /Users/qulturerocks/.rvm/scripts/rvm
- Install Brew (
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
) - Go to folder
cd QultureApp
- Install Ruby if not automatic:
rvm install ruby-2.5.3
- Install postgresql (
brew install postgresql
)
- Run
/etc/init.d/postgresql stop
to ensure that you don't have postgresql running at the moment - Start postgresql with
pg_ctl -D /usr/local/var/postgres start
- Install bundler (
gem install bundler
)
- If it cannot find bundler try
gem install bundler --source http://rubygems.org
- Run bundler (
bundle install
)
- Create a super user with the same name of the computer account (
sudo -u postgres createuser --interactive
) - Run
rake db:create
- Run
rake db:migrate
- Run
rake db:seed
Run rails s
(this will run the server on port 3000)
You can always run rails routes
to see all the routes, but here they are:
GET /api/v1/users api/v1/users#index
POST /api/v1/users api/v1/users#create
GET /api/v1/users/:id api/v1/users#show
PATCH /api/v1/users/:id api/v1/users#update
PUT /api/v1/users/:id api/v1/users#update
DELETE /api/v1/users/:id api/v1/users#destroy
GET /api/v1/users/:user_id/comments api/v1/comments#index
POST /api/v1/comments api/v1/comments#create
GET /api/v1/comments/:id api/v1/comments#show
PATCH /api/v1/comments/:id api/v1/comments#update
PUT /api/v1/comments/:id api/v1/comments#update
DELETE /api/v1/comments/:id api/v1/comments#destroy