Equivalent scrapbook

…scrap on Omniauth

instalation

http://railscasts.com/episodes/235-omniauth-part-1
http://railsforum.com/viewtopic.php?id=45315
https://github.com/intridea/omniauth/tree/1.0-beta
http://rubydoc.info/gems/omniauth/0.2.6/frames
http://railscasts.com/episodes/241-simple-omniauth
https://github.com/intridea/omniauth/wiki

Gemfile

gem 'omniauth'

config/enviromnets/devel..

  Rails.application.config.middleware.use OmniAuth::Builder do
    provider :twitter, 'NIOQjMvmAi3QdErtDwdeA', 'baaoutnaoetnsuhaosr'
    provider :facebook, '238909386152208', 'ec2d8b2bar'
    provider :github, '38c9c9df5734d73eeb8a', 'aoeusaounsaotesutaoesuusoats'

    provider :openid, OpenID::Store::Filesystem.new('/tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
    #provider :linked_in, 'CONSUMER_KEY', 'CONSUMER_SECRET'
  end
class CreateAuthentications < ActiveRecord::Migration
  def change
    create_table :authentications do |t|
      t.integer :user_id
      t.string :provider
      t.string :uid
      t.text :user_info

      t.timestamps
    end
  end
end

sessions controller

config/routes.rb

match "/auth/:provider/callback" => "sessions#create"
match "/signout" => "sessions#destroy", :as => :signout

view file

<% if current_user %>
  Welcome <%= current_user.name %>!
  <%= link_to "Sign Out", signout_path %>
<% else %>
  <%= link_to "Sign in with Twitter", "/auth/twitter" %>
<% end %>

app/c/application_c..

helper_method :current_user

  private

  def current_user
    @current_user ||= User.find(session[:user_id]) if session[:user_id]
  end