我正在使用我在这篇文章的标题中写的这三个 gem 开发一个应用程序。我使用可确认模块(?)设置了设计,因此当用户使用其电子邮件/密码创建帐户时,它会收到一封确认电子邮件。如果用户使用 facebook(使用 omniauth-facebook gem)注册,则设计会跳过确认步骤。
在用户.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
...
当我为向导添加邪恶的宝石时,事情就来了。我配置了路由文件
在路线.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 注册时,向导永远不会出现。
有什么提示???
谢谢!!