この記事のタイトルに書いた、この 3 つの gem を使用してアプリケーションを開発しています。確認可能なモジュール (?) を使用してデバイスをセットアップしたので、ユーザーがメール/パスワードでアカウントを作成すると、確認メールが届きます。ユーザーが facebook で (omniauth-facebook gem を使用して) サインアップした場合、devise は確認ステップをスキップします。
user.rb 内
"Of course the :confirmable is active in the model"
...
# Omniauth-facebook
def self.find_for_facebook_oauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
user.first_name = auth.info.first_name
user.last_name = auth.info.last_name
user.skip_confirmation!
# user.image = auth.info.image # assuming the user model has an image
end
end
...
ウィザードに邪悪な宝石を追加したときに問題が発生しました。ルートファイルを構成しました
routes.rb で
MyApp::Application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks",
:registrations => "registrations" }
root 'home#index'
# Registration wizard routes
resources :after_register
end
デバイス登録メソッドをオーバーライドするための registration_controller を作成しました
class RegistrationsController < Devise::RegistrationsController
def create
super
end
protected
def after_sign_in_path_for(resource)
puts "<<<<<<<<<<<<<<<< SIGN IN"
after_register_path(:import_contacts)
end
def after_sign_up_path_for(resource)
puts "<<<<<<<<<<<<<<<< SIGN UP ACTIVE"
after_register_path(:import_contacts)
end
def after_inactive_sign_up_path_for(resource)
puts "<<<<<<<<<<<<<<<< SIGN IN INACTIVE"
after_register_path(:import_contacts)
end
end
そして、Wicked でウィザードの手順を処理する新しいコントローラーを作成しました。
class AfterRegisterController < ApplicationController
include Wicked::Wizard
before_filter :authenticate_user!
steps :import_contacts, :select_agents, :wish_form
def show
@user = current_user
render_wizard
end
def update
@user = current_user
@user.attributes = params[:user]
render_wizard @user
end
end
メール/パスワードでユーザーを作成すると、ウィザードが表示され、すべて正常に動作しますが、Facebook でサインアップしようとすると、ウィザードが表示されません。
何かヒント???
ありがとうございました!!