Rails Website for QuoiQuoi studio
You can use this project to the case study for Rails in real business website.
Run rake secret to obtain a strong secret token and put it into config/initializers/secret_token.rb.
QuoiQuoi::Application.config.secret_key_base = 'TOKEN FROM [rake secret]'Run devise:install command in your project. Devise getting started
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.
OmniAuth.config.full_host = Rails.env.production? ? 'https://YOUR_PRODUCTION_DOMAIN' : 'http://localhost:3000'
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, 'OAUTH_TOKEN'
provider :facebook, 'APP_ID', 'APP_SECRET'
endQuoiQuoi 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).
Recaptcha.configure do |config|
config.site_key = 'YOUR_RECAPTCHA_SITE_KEY'
config.secret_key = 'YOUR_RECAPTCHA_SECRET_KEY'
endUnfortunately we has not upgrade to invisible reCAPTCHA, it is a TO-DO item.
Register a REST app in paypal developer.
development: &sandbox # change to your own
username: SET_YOUR_OWN
password: SET_YOUR_OWN
signature: SET_YOUR_OWN
sandbox: true
test:
<<: *sandbox
production: &production
username: SET_YOUR_OWN
password: SET_YOUR_OWN
signature: SET_YOUR_OWN
sandbox: falseECPay 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.
require 'allpay'
AllPay.setup do |allpay|
if Rails.env.production?
allpay.merchant_id = 'write your production merchant_id'
allpay.hash_key = 'write your production hash_key'
allpay.hash_iv = 'write your production hash_iv'
else
allpay.merchant_id = 'write your development merchant_id'
allpay.hash_key = 'write your development hash key'
allpay.hash_iv = 'write your development hash iv'
end
endECPay 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.
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.
rake assets:precompile RAILS_ENV=production or just start up webrick server rails s, compass will compile all scss files automatically in dev.
sidekiq -q mailers,1 -q default,1. You can run the Supervisor to protect sidekiq job.
Modify config/unicorn.config to fit your requirement then run unicorn -c config/unicorn.config -D -E production.