Tophat Reddit-esque take home assignment from Rob Kalsi
Follow steps to get the project up and running on your local
Install gcc
and g++
C/C++ compiler for your platform if not already installed
Clone this repo
Ruby Version Manager (RVM) https://rvm.io/
Install RVM to be able to manage different ruby versions
- do not install rails at the same time
Use RVM to install ruby
- go into the repo directory
rvm install 3.1.0
- note depending on your platform this might need to compile if it can't find pre-compiled binaries
Install Postgres for your platform if not already installed
- make the following databases:
tophat_dev
,tophat_test
,tophat_prod
- make the following user/pass:
test/blah
andGRANT ALL PRIVILEGES
to the three databases created above - make the user created in the above step a
SUPERUSER
Install Redis server for your platform if not already installed
- if you have already setup Redis with a login/pass, you will have to modify
DiscussionQuestionPost.redis_connection
and supply the correct credentials
Bundler lets you install all of the rubygems as listed in Gemfile
- go into repo directory
gem install bundler
Use bundler to install all of the gems
- go into repo directory
bundle install
The databases need to be migrated, this is accomplished by using rails migration files, and must be done for dev
and test
- go into repo directory
rake db:migrate
RAILS_ENV=test rake db:migrate
Run the seeding script to populate the dev environment with some data
- go into repo directory
rake db:seed
See if the project is mostly functional by going into the console
- go into repo directory
rails c
- type
exit
to leave
Can run tests to ensure project is functional
- go into repo directory
rspec spec
Run the web server to load API docs
- go into repo directory
rails s
- navigate to the site on your browser and go to
http://localhost:3000/api-docs
- note that your port after
localhost
might be different, use the port thatrails s
is listening on - note that the "Try It Out" button likely will not work
- you should be able to make simple
GET
calls in your browser at this point as well
Listing the DiscussionQuestionPosts
can be in a Flat or Tree structure using the hierarchy
url parameter
http://localhost:3000/discussion_question_posts
for flathttp://localhost:3000/discussion_question_posts?hierarchy=tree
for tree