-
Notifications
You must be signed in to change notification settings - Fork 4
Setting up your development environment
This guide assumes you are a developer interested in contributing to this project, these are the steps to get you started with your development environment.
- Fork the project by visiting the project page and clicking the Fork button.
- Clone your fork of the project:
git clone git@github.com:your_user/usergroup.git
The application comes with an example config/application.yml.example
file which has a basic setup (a non-working one of course) of your GitHub OAuth secret and id.
To set them up you'll need to register a new application in GitHub here, make sure that both the callback and application url are the same and that both url's map the url you'll be working from.
Then you need to create two environment variables GITHUB_ID
and GITHUB_SECRET
like this:
export GITHUB_ID=yourgithubidgoeshere
export GITHUB_SECRET=yourgihubsecretgoeshere
Then just run rake config:application
to generate application.yml
, or you can run rake config:generate
to generate all config files.
Don't worry about setting your keys there config/application.yml
is automatically ignored by git so it won't be tracked.
You'll need to install postgresql first, after you have postgresql running just follow these steps:
-
(optional) Set the
DATABASE_USERNAME
andDATABASE_PASSWORD
environment variables, you can do this like this:
export DATABASE_USERNAME=user
export DATABASE_PASSWORD=password
Note: If not ser database username will be set to postgres
and password will be blank.
- Run
rake config:database
to createdatabase.yml
orrake config:generate
to generate all files. - Edit this file with your new username say
usergroup
:
You may be wondering why we set it to postgres in the defaults instead if we're changing it in our env, the answer is simple, the postgres
user is what travis-ci uses on it's builds.
- Create a user for that database with the name
usergroup
(or whatever you like really).
sudo -u postgres createuser usergroup -P
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
Note: If you want a password-less account just remove the -P
part from the createuser
command.
As you might have guessed this new user does not need to be superuser nor to create new roles.
- Create the needed databases, luckily rails offer us a simple way to do this:
rake db:create:all
- Finally run all missing migrations
rake db:migrate
You first need to install nginx.
The app comes with an nginx config generator, if you wish to use nginx
instead of rails default webserver webrick
you'll need to run rake config:generate
and add the following to your nginx.conf
under the http
block:
include "/path/to/your/usergroup/config/vhost.conf";
If you're using apache
instead then you were lucky, just make your DocumentRoot
point to the public
folder:
DocumentRoot "/path/to/your/public"
And run rake config:htaccess
to generate a .htaccess
file or rake config:generate
to generate all configuration files. This will generate a file like this:
PassengerEnabled on
PassengerAppRoot /path/to/your/public
RailsEnv development
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.rt.dev/$1 [R=301,L]
Options -Indexes FollowSymLinks SymLinksIfOwnerMatch
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<FilesMatch "\.(html|css|js)$">
SetOutputFilter DEFLATE
</FilesMatch>
FileETag none
We use www.rt.dev
as the default development address, this is not a valid domain but you can edit your /etc/hosts
file and add the following:
127.0.0.1 www.rt.dev rt.dev
After the file is saved and closed pinging rt.dev will ping 127.0.0.1 and your nginx setup will work with that address out of the box.
Just go into your project folder and install them with bundle
, if you don't have bundle installed you can sudo gem install bundler
:
cd usergroup
bundle
All tests are written in Rspec
and the spec task is the default task so just run rake
and watch the test run.