【发布时间】:2014-02-15 14:04:40
【问题描述】:
我正在使用我在这篇文章的标题中写的这三个 gem 开发一个应用程序。我使用可确认模块(?)设置了设计,因此当用户使用其电子邮件/密码创建帐户时,它会收到一封确认电子邮件。如果用户使用 facebook 注册(使用 omniauth-facebook gem),则设计会跳过确认步骤。
在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 注册时,向导永远不会出现。
任何提示???
谢谢!!
【问题讨论】:
-
你能告诉我你是如何使用 render_wizard 编写视图文件的
标签: ruby-on-rails ruby devise omniauth wicked-gem