我正在使用设计 2.0 和 gem omniauth-twitter
问题是 twitter 没有发送电子邮件作为响应,所以我的应用程序的模型用户验证有一封电子邮件,我在回调中收到以下错误:
Email can't be blank
我的user.rb模型中有这个:
#config omniauth twitter
def self.find_for_twitter_oauth(access_token, signed_in_resource = nil)
data = access_token.extra.raw_info
if user = User.where(:username => data.screen_name).first
user
else
User.create!(:username => data.screen_name, :password => Devise.friendly_token)
end
end
我的omniauth_callbacks_controller.rb中有这个
def twitter
@user = User.find_for_twitter_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Twitter"
sign_in_and_redirect @user, :event => :authentication
else
# http://stackoverflow.com/questions/7117200/devise-for-twitter-cookie-overflow-error
session["devise.twitter_data"] = request.env["omniauth.auth"].except('extra')
redirect_to new_user_registration_url
end
end
我想强制用户提供用于发送时事通讯、广告商...等的电子邮件地址
我该如何解决这个问题?
谢谢!