0
我不知道如何管理更新通过Omniauth注册的用户数据 - 例如,如果我在twitter上更新我的profil图片,则会显示profil图片我的网络应用程序未更新,并会显示损坏。使用omniauth(微博)登录时更新用户数据
我的用户模型设置如下:
应用程序/模型/ user.rb
class User < ActiveRecord::Base
has_merit
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
extend FriendlyId
friendly_id :name, use: :slugged
def should_generate_new_friendly_id?
new_record?
end
devise :database_authenticatable, :registerable,:omniauthable,
:recoverable, :rememberable, :trackable, :validatable
validates :email, presence: true,
uniqueness: true
has_many :pins, :dependent => :destroy
has_many :comments, :dependent => :destroy
has_many :votes, dependent: :destroy
has_many :upvoted_pins, through: :votes, source: :pin
has_many :rewards, dependent: :destroy
has_many :rewarded_pins, through: :rewards, source: :pin
has_many :badges
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.nickname
user.image = auth["info"]["image"]
user.description = auth.info.description
end
end
def self.new_with_session(params, session)
if session["devise.user_attributes"]
new(session["devise.user_attributes"]) do |user|
user.attributes = params
user.valid?
end
else
super
end
end
def password_required?
super && provider.blank?
end
def update_with_password(params, *options)
if encrypted_password.blank?
update_attributes(params, *options)
else
super
end
end
end
嘿我试了很多东西来实现这一点,但它仍然在工作 - 我不能得到te配置文件图片更新omniauth ...任何想法? – zacchj 2014-09-06 13:20:36