mkdir foo
cd foo
curl -o "Vagrantfile" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/171c5027732476f433b6cb97963382e3896fada0/Vagrantfile"
vagrant up && vagrant ssh
# 以下、vagrant内
cd /vagrant
gem install rails --no-rdoc --no-ri
rails new ./ --database=postgresql
echo 'gem "google-api-client", "~> 0.7.1"' >> Gemfile
echo 'group :production do' >> Gemfile
echo ' gem "newrelic_rpm"' >> Gemfile
echo ' gem "rails_12factor"' >> Gemfile
echo 'end' >> Gemfile
bundle install
psql template1 -c "CREATE DATABASE development"
psql template1 -c "CREATE DATABASE test"
curl -o "config/database.yml" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/50f40d245409129c64ef553d7fa228e7092d495f/database.yml"
rails g model team
rails g model google_account
rails g model user
rm db/migrate/*.rb
curl -o "db/migrate/20140101000000_create_google_auth.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/e344ef51ec54e1312637d0a81455bb69443ecbf7/20140101000000_create_google_auth.rb"
rake db:migrate
rm app/models/*.rb
curl -o "app/models/team.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/ac306295857f09be9d6428f4cd68a0144df127f5/team.rb"
curl -o "app/models/user.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/22401ffd6941843999ed8101313239c7d502ec25/user.rb"
curl -o "app/models/google_account.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/118bb5675db0eeeeb86fdfab7c6a5c23233f1522/google_account.rb"
rails g controller oauth/google
rails g controller sessions
rails g controller dashboard show
curl -o "app/controllers/sessions_controller.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/71a95d59f02578f58bbbc096ffc943e7505d6db3/sessions_controller.rb"
curl -o "app/controllers/oauth/google_controller.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/5b441e3ddb090b1a339f3cd2689f13b0fbf17d6f/google_controller.rb"
curl -o "app/controllers/dashboard_controller.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/d563863b34dfbe6814775fa6ce7e48880b32fe87/dashboard_controller.rb"
curl -o "app/views/dashboard/show.html.erb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/c49ad450a6630b5dd6bb7178491930c594dbeedc/dashboard_show.html.erb"
curl -o "app/helpers/application_helper.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/d32000a590e478fc405bc2141b1211dc72f017dd/application_helper.rb"
curl -o "app/controllers/concerns/require_team.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/de5c479b535c9c9308124c04628f88773f133410/require_team.rb"
curl -o "app/controllers/concerns/authentication.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/c99e45edb7f2308800506a5799b3c836cf09e629/authentication.rb"
curl -o "config/routes.rb" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/7fe7c02dac22e3a9c31b9d1114a3d2d61c5cd6c8/routes.rb"
Google認証のKeyを設定。
https://console.developers.google.com/project から生成
development:
client_id: 0000000000-apps.googleusercontent.com
client_secret: AAAA-BBBB-CCCC
production:
client_id: 9999999999-.apps.googleusercontent.com
client_secret: DDDD-EEEE-FFFFF