ボクココ

個人開発に関するテックブログ

Rails3, Mongoid, OmniAuth でFacebookログイン実装

最初はやはり認証。これができないと何もアプリ作れない。


$ rails new youme -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-mongoid-omniauth-template.rb -T -O
Github から実装テンプレートを取ってくる。HTTPSの証明書エラーが出たので、ここ http://railsapps.github.com/openssl-certificate-verify-failed.html を参考にして解決。

[homma@localhost rails]$ rails new youme -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-mongoid-omniauth-template.rb -T -O
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/application.html.erb
create app/mailers/.gitkeep
create app/models/.gitkeep
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create db
create db/seeds.rb
create doc
create doc/README_FOR_APP
create lib
create lib/tasks
create lib/tasks/.gitkeep
create lib/assets
create lib/assets/.gitkeep
create log
create log/.gitkeep
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/index.html
create public/robots.txt
create script
create script/rails
create tmp/cache
create tmp/cache/assets
create vendor/assets/javascripts
create vendor/assets/javascripts/.gitkeep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.gitkeep
create vendor/plugins
create vendor/plugins/.gitkeep
apply https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-mongoid-omniauth-template.rb
initializer generators.rb
wizard You are using Rails version 3.2.3.
wizard Checking configuration. Please confirm your preferences.
insert config/application.rb
recipe Running HAML recipe...
haml Would you like to use Haml instead of ERB? (y/n) n
recipe Running RSpec recipe...
rspec Would you like to use RSpec instead of TestUnit? (y/n) y
rspec Would you like to use factory_girl for test fixtures with RSpec? (y/n) y
rspec Would you like to use machinist for test fixtures with RSpec? (y/n) y
gemfile rspec-rails (>= 2.9.0.rc2)
gemfile database_cleaner (>= 0.7.2)
gemfile mongoid-rspec (>= 1.4.4)
gemfile machinist
gemfile factory_girl_rails (>= 3.0.0)
gemfile email_spec (>= 1.2.1)
create features/support/email_spec.rb
recipe Running Cucumber recipe...
cucumber Would you like to use Cucumber for your BDD? (y/n) y
gemfile cucumber-rails (>= 1.3.0)
gemfile capybara (>= 1.1.2)
gemfile database_cleaner (>= 0.7.2)
gemfile launchy (>= 2.1.0)
recipe Running guard recipe...
question Would you like to use Guard to automate your workflow?
1) No
2) Guard default configuration
3) Guard with LiveReload
guard Enter your selection: 1
guard Guard recipe skipped.
recipe Running Mongoid recipe...
mongoid Would you like to use Mongoid to connect to a MongoDB database? (y/n) y
mongoid REMINDER: When creating a Rails app using Mongoid...
mongoid you should add the '-O' flag to 'rails new'
gemfile bson_ext (>= 1.6.1)
gemfile mongoid (>= 2.4.7)
recipe Running SeedDatabase recipe...
recipe Running OmniAuth recipe...
omniauth Would you like to use OmniAuth for authentication? (y/n) y
question Which service provider will you use?
1) Twitter
2) Facebook
3) GitHub
4) LinkedIn
5) Google
omniauth Enter your selection: 2
gemfile omniauth (>= 1.0.3)
gemfile omniauth-facebook
recipe Running HomePage recipe...
recipe Running HomePageUsers recipe...
recipe Running html5 recipe...
question Which front-end framework would you like for HTML5 and CSS?
1) None
2) Zurb Foundation
3) Twitter Bootstrap (less)
4) Twitter Bootstrap (sass)
5) Skeleton
6) Just normalize CSS for consistent styling
html5 Enter your selection: 1
recipe Running UsersPage recipe...
recipe Running OmniAuthEmail recipe...
recipe Running Cleanup recipe...
recipe Running Extras recipe...
extras Would you like to use 'rails-footnotes' (it's SLOW!)? (y/n) y
extras Would you like to set a robots.txt file to ban spiders? (y/n) y
extras Extras recipe running 'after bundler'
gemfile rails-footnotes (>= 3.7)
extras BanSpiders recipe running 'after bundler'
recipe Running Git recipe...
recipe Running AddUser recipe...
wizard Running 'bundle install'. This will take a while.
run bundle install from "."