Skip to content

Developer Setup & Notes

Nicolas Garcia edited this page Sep 18, 2017 · 32 revisions

How to Set Up 1-Click Locally

1. Prerequisites

The following need to be installed.

  • git
  • postgres
  • postgis
  • rbenv (ruby package manager)
  • ruby

Install all of your prequisites using homebrew

brew install git postgres postgis rbenv ruby-build

Add rbenv to bash so that it loads every time you open a terminal

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

Install Ruby

rbenv install 2.4.0
ruby -v

2. Clone the Project

git clone https://github.com/camsys/oneclick-core.git

3. Setup rbenv

Setup rbenv to default to ruby 2.4.0

cd oneclick-core
rbenv local 2.4.0

4. Install Bundler and Gems

Install bundler and install gems.

gem install bundler
bundle install

5. Create Your Database

Create your database.

Note: Ensure postgres is running before executing the following command. Optional: Set postgres to turn on at startup

alias start-psql='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
alias stop-psql='pg_ctl -D /usr/local/var/postgres stop -s -m fast'

This creates your development database, loads the schema, and populates seed data.

rake db:setup

Optional: Add sample data to your development setup.

rake db:sample:all

6. Start Your Server

rails s

Open a browser and go to localhost:3000.

Login with

email: [email protected]
pword: welcome1

Developer Notes

PostGIS database reset issue

You may run into the following error when running migrations, especially during rake db:reset:

PG::UndefinedObject: ERROR:  type "geometry" does not exist

To fix this, follow the steps outlined here (https://stackoverflow.com/questions/7001447/postgis-error-type-geography-does-not-exist):

  1. Open the psql console. On heroku, you can do this by running heroku pg:psql -a app-name
  2. Make sure you're connected to the right database, and run CREATE EXTENSION Postgis;
  3. Quit psql with \q.
  4. Re-run migrations; they should work now.

OneClick Module Engines

Modules are included by adding the module name as an environment variable, set to any truthy value (e.g. "true"). Locally, this can be achieved by creating a config/oneclick_modules.rb file. This can be copied over from config/oneclick_modules.rb.sample as a starting point. On Heroku, these variables can be set directly as heroku config variables.

ONECLICK REFERNET

To set up the OneclickReferNET engine:

Locally:

  1. Create a copy of config/oneclick_modules.rb.sample in the config directory and rename it oneclick_modules.rb.
  2. Ensure that the ONECLICK_MODULES array includes the string "ONECLICK_REFERNET", and that below this array is the block that sets the ENV variable based on the ONECLICK_MODULES array.
  3. run bundle install and rake db:migrate
  4. run rake oneclick_refernet:load_database to import the ReferNET database. This will take a while.

Heroku:

  1. In the Settings tab for your app, click "Reveal Config Vars". Create a new variable with KEY = ONECLICK_REFERNET and VALUE = true.
  2. May need to do heroku restart -a app-name or something to get it to reinstall gems.
  3. run heroku run rake db:migrate -a app-name
  4. run rake oneclick_refernet:load_database to import the ReferNET database. This will take a while.