Installing Quill-Lessons
1. Install rbenv and postgres.
For help on how to do this, refer to the beginning portion of the 'Install Empirical Core on your local machine' doc (for OSX or for Linux .
2. Clone Quill-Lessons
Navigate to the directory that you'd like the Quill-Lessons app to live in. Then run:
git clone [email protected]:empirical-org/Quill-Lessons.git
And move to the develop branch:
git checkout develop
Then create a config/database.yml file using config/database.yml.example:
cp config/database.yml.example config/database.yml
Make sure that in the .env file, the field 'QUILL_CLIENT_SECRET' is set to the value 'not-a-secret', such that the following line is included:
QUILL_CLIENT_SECRET=not-a-secret
3. Create a second database cluster for postgres
To get both Quill-Lessons and Empirical Core both running at the same time on your machine, you're going to need two server instances of postgres running.
Each server instance of postgres requires its own database cluster, which has it's own data directory. To create the database cluster for Empirical-Core, you likely used a command of the following form:
initdb /usr/local/var/postgres
The argument /usr/local/var/postgres specifies where you want a data directory to be created for the new database cluster.
If you already created a data directory in that location for Empirical-Core, you'll need to create one in a new location, such as /usr/local/var/postgres2, using a command of the following form:
initdb /usr/local/var/postgres2
You can look here for more information on the initdb command.
4. Configure different port for postgres
Since you'll have two instances of postgres running, you're going to need them to be communicating with your two apps (Empirical Core and Quill Lessons) over two different ports. The default port for postgres is 5432, so we'll let Empirical Core communicate with it's postgres instance over 5432 and specify that Quill-Lessons communicate over 5433. Doing this involves two measures:
A. add 'port: 5433` to config/database.yml, so it looks like this:
development:
adapter: postgresql
encoding: unicode
database: quill_lessons_development
port: 5433
B. When you fire up Quill-Lessons' instance of postgres, specify the port in the command:
postgres -D /usr/local/var/postgres2 -h localhost -p 5433
5. Have Quill-Lessons listen on a different web port
Empirical-Core will be listening on localhost:3000, so when you fire up the rails server for Quill-Lessons, have it listen on a different local url, such as localhost:3002, using the following command:
rails s -p 3002
6. Sync ActivityClassification records on Empirical Core
When you installed Empirical Core, you used the command rake db:setup
to set up it's database. This command should have created some initial 'seed' records in the Empirical Core database, including two ActivityClassification records that correspond to activities provided by Quill Lessons. Each of these records includes an expectation that Empirical Core makes of which local web port Quill Lessons will be listening on. Namely, the fields 'form_url' and 'module_url' include the expected Quill Lessons local web port as a base url.
Whatever local web port you have chosen Quill-Lessons to listen on, make sure that those fields reflect that port. So for example, if you have Quill-Lessons listening on 'http://localhost:3002', then make sure that the ActivityClassification record in Empirical Core's database which has name 'Practice Questions' has for its form_url http://localhost:3002/practice_questions/form
, and has for its module_url http://localhost:3002/practice_questions/module
.
7. Sync Oauth information
In the Empirical Core database, there is a table called oauth_applications which stores information about the third party apps which will interact with it (including Quill-Lessons). This table is managed through the doorkeeper gem, and so is not available through ActiveRecord. However, it can be modified using the postgres command line tool. A record in this table should already exist that corresponds to Quill-Lessons (it is inserted when Empirical Core is installed and rake db:seed is called to seed Empirical-Core's databse).
One must make sure that the field 'redirect_uri' on this record is correct (given current codebase, it is not). If you are having Quill-Lessons listen on localhost:30002, then the value for this field should be 'http://localhost:3002/oauth/callback'. If you are having Quill Lessons listen on a different address, then simply substitute that address in for 'localhost:3002'. To make this modification, first fire up the postgres command line tool:
psql emp_gr_development
where the argument emp_gr_development represents the name of the database that your local version of Empirical Core is using in its development environment (can be confirmed by looking at config/database.yml in the directory of your local Empirical Core codebase).
Upon firing up the psql command line tool, use the following sql update statement:
update oauth_applications set redirect_uri='http://localhost:3002/oauth/callback' where uid='quill-lessons'
8. Remove deprecated portions of seed, then setup database
Remove any statements mentioning the table 'grammar_rules' or the table 'rules_misseds' from Quill-Lessons/db/seed.sql. Then get the Quill-Lessons database ready to go with the following commands:
rake db:create
rake db:schema:load
rake db:migrate
rake db:seed
Updated about 2 months ago