项目作者: CapsLock-Studio

项目描述 :
Rails Website for QuoiQuoi studio
高级语言: Ruby
项目地址: git://github.com/CapsLock-Studio/QuoiQuoi.git
创建时间: 2014-02-21T06:14:19Z
项目社区:https://github.com/CapsLock-Studio/QuoiQuoi

开源协议:

下载


" class="reference-link">QuoiQuoi build-status Dependency Status

Rails Website for QuoiQuoi studio

About

You can use this project to the case study for Rails in real business website.

Environment

  • ruby-version
  • Redis
  • PostgreSQL

Which techs used in this project.

ActiveJobs

Configurations

Run rake secret to obtain a strong secret token and put it into config/initializers/secret_token.rb.

  1. QuoiQuoi::Application.config.secret_key_base = 'TOKEN FROM [rake secret]'

Set up devise

Run devise:install command in your project. Devise getting started

Add secrets for omni-auth

QuoiQuoi support user sign in with Google or Facebook by omni-auth. You have to apply your test app at Google API Console and Facebook for Developers.

After registering your app and putting these keys and secrets into config/initiailizers/omniauth.rb. There is a little different to OmniAuth getting started document. We supply omni-auth hull host variable for sign in from email token.

  1. OmniAuth.config.full_host = Rails.env.production? ? 'https://YOUR_PRODUCTION_DOMAIN' : 'http://localhost:3000'
  2. Rails.application.config.middleware.use OmniAuth::Builder do
  3. provider :google_oauth2, 'OAUTH_TOKEN'
  4. provider :facebook, 'APP_ID', 'APP_SECRET'
  5. end

Set up reCAPTCHA v2

QuoiQuoi allows users to register courses without sign in, reCAPTCHA protect our service from BOT attack, it really good. You have to Get reCAPTCHA and add key and secret to config/initializers/recaptcha.rb (Alternative API key setup).

  1. Recaptcha.configure do |config|
  2. config.site_key = 'YOUR_RECAPTCHA_SITE_KEY'
  3. config.secret_key = 'YOUR_RECAPTCHA_SECRET_KEY'
  4. end

Unfortunately we has not upgrade to invisible reCAPTCHA, it is a TO-DO item.

Paypal

Register a REST app in paypal developer.

  1. development: &sandbox # change to your own
  2. username: SET_YOUR_OWN
  3. password: SET_YOUR_OWN
  4. signature: SET_YOUR_OWN
  5. sandbox: true
  6. test:
  7. <<: *sandbox
  8. production: &production
  9. username: SET_YOUR_OWN
  10. password: SET_YOUR_OWN
  11. signature: SET_YOUR_OWN
  12. sandbox: false

ECPay

ECPay is a payment solution and pretty easy to integrate in Taiwan.

You have to register the developer account in ECPay, then put your merchant id, hash key, and iv to config/initializers/allpay.rb.

  1. require 'allpay'
  2. AllPay.setup do |allpay|
  3. if Rails.env.production?
  4. allpay.merchant_id = 'write your production merchant_id'
  5. allpay.hash_key = 'write your production hash_key'
  6. allpay.hash_iv = 'write your production hash_iv'
  7. else
  8. allpay.merchant_id = 'write your development merchant_id'
  9. allpay.hash_key = 'write your development hash key'
  10. allpay.hash_iv = 'write your development hash iv'
  11. end
  12. end

ECPay will send the payment result at path http://domain.com/order_payment_callback/allpay_complete, http://domain.com/registration_payment_callback/allpay_complete by POST method. So if you want to try payment in localhost it will be impossible.

Start Rails App

Migrate DB

Ensure your role have privilege to create database and run rake db:create or rake db:create RAILS_ENV=production, if no, you need do it manually.

QuoiQuoi use PostgreSQL in production environment, you can use SQLite in dev but this is not recommended because extract query is not supported in SQLite.

Precompile assets

rake assets:precompile RAILS_ENV=production or just start up webrick server rails s, compass will compile all scss files automatically in dev.

Run sidekiq for jobs queue

sidekiq -q mailers,1 -q default,1. You can run the Supervisor to protect sidekiq job.

Unicorn

Modify config/unicorn.config to fit your requirement then run unicorn -c config/unicorn.config -D -E production.