Skip to content

wata-gh/survey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

48a38e2 · Jul 28, 2016
May 9, 2016
Sep 16, 2015
Oct 11, 2015
Oct 2, 2015
Sep 29, 2015
Sep 25, 2015
Sep 16, 2015
Sep 16, 2015
Sep 26, 2015
Oct 11, 2015
Sep 21, 2015
Sep 27, 2015
Sep 16, 2015
Sep 25, 2015
Sep 29, 2015
Oct 11, 2015
Oct 11, 2015
Oct 2, 2015
Sep 16, 2015
Sep 26, 2015
Sep 25, 2015
Sep 16, 2015
Sep 29, 2015
Sep 21, 2015

Repository files navigation

survey

This project is survey web system. Can create surveys and anaylize feedback.

Code Climate Test Coverage

Installation

First create server which survey-prov itamae provisioning.

# clone source
git clone https://github.com/wata-gh/survey.git
cd survey

# bundle install gems
bundle --path vendor/bundle

# create database
RAILS_ENV=production bundle exec rake db:create

# apply db
bundle exec ridgepole -c config/database.yml --apply -f db/Schemafile --env production

# npm install
npm install

# install bower components
./bin/rake bower:install['-f']

# precompile assets
bundle exec rake assets:precompile

# start unicorn
RAILS_ENV=production ./bin/rake unicorn:start

After starting unicorn application, you needs to create default group. If your domain is survey.example.com. you need to insert data to groups table.

insert into groups (
  name, description, created_at, updated_at
) values (
  'survey', 'default group', now(), now()
);

If your not using groups or access by IP, you can simply set name to blank.

insert into groups (
  name, description, created_at, updated_at
) values (
  '', 'default group', now(), now()
);

Settings

By default, storage is Amazon S3. But you can change storage to local disk.

Survey uses S3 storage so you need to set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environments.

export AWS_ACCESS_KEY_ID=[AWS access key]
export AWS_SECRET_ACCESS_KEY=[AWS secret key]
export RAILS_ENV=production

config/initializers/carrierwave.rb

config.fog_credentials = {
  provider: 'AWS',
  aws_access_key_id: Rails.application.secrets.aws_access_key_id,
  aws_secret_access_key: Rails.application.secrets.aws_secret_access_key,
  region: 'ap-northeast-1'
}

Doesn't matter which storage you use, you have to set nginx or something to able to access images. You can use nginx+small_light docker image to do that. Just set Amazon S3 url to image.conf and build image and start.

image_server/nginx/conf.d/image.conf

server {
    listen 80 default_server;

    access_log  /var/log/nginx/survey.image.access.log main;
    root   /opt/survey/public;

    small_light on;

    location ~ ^/resize/w/(.+)/h/(.+?)/(.+)$ {
        set $width $1;
        set $height $2;
        set $file $3;
        set $engine "imagemagick";
        proxy_pass http://127.0.0.1/small_light(dw=$width,dh=$height,e=$engine)/images/$file;
    }

    location ~ small_light[^/]*/(.+)$ {
        set $file $1;
        rewrite ^ /$file;
    }

    location /images/ {
        proxy_pass https://s3-ap-northeast-1.amazonaws.com/[bucket name]/;
    }
}

If you are using docker-compose, just start docker image by following command.

docker-compose up -d

Getting Started

Access to survey with your domain and create new survey.
e.g.
http://survey.example.com