rspecを使うので、--skip-test-unit
rails new app_name -T --skip-test
rm public/index.html app/assets/images/rails.png
Gemfileに必要なものを追加してbundle
bundle
rails g rspec:install
OmniAuth用のUser ModelとSessions Controllerを用意、Sessions Controllerにcreateとdestroyを実装しておく
rails g model User provider:string uid:string name:string
rails g controller Sessions
User Modelにcreate_with_omniauthを実装
def self.create_with_omniauth(auth)
create!do |user|
user.provider = auth["provider"]
user.uid = auth["uid"]
if user.provider == "facebook"
user.name = auth["info"]["name"]
else
user.name = auth["info"]["nickname"]
end
end
end
必要に応じてmigrationをいじってdb:migrate
rake db:migrate
初期化ファイル
#config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :developer unless Rails.env.production?
provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
end
routes.rbを編集
match '/auth/:provider/callback', to: 'sessions#create'
twitter-bootstrap-railsの設定
rails g bootstrap:install
formtasticの設定
rails generate formtastic:install
config/initializers/formtastic.rbに追加
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
app/assets/stylesheets/application.cssに追加
*= require formtastic-bootstrap
config/unicorn.rb
spork --bootstrap
bundle exec guard init rspec
bundle exec guard init rails-assets
bundle exec guard init bundler
bundle exec guard init spork
bundle exec guard init livereload
livereloadのブロックを一番上にもっていく
git init
git add .
git commit -m "Project creation and basic setups"
git co -b new_branch
bundle exec guard
rails s
# or bundle exec unicorn_rails -c config/unicorn.rb
rails g model ....