1

我正在使用来自的代码组合

http://railscasts.com/episodes/360-facebook-authentication?view=asciicast

oauth 部分并尝试将其与 neo4J 集成

https://github.com/neo4jrb/neo4j

据我所知,这个 gem 替换了许多活动记录,包括数据类型。

我正在尝试替换这段代码。他们将它们oauth_expires_at设置为日期时间数据类型,我不相信 neo4j gem 有(我假设我不能使用 datetype,因为在这种情况下活动记录被 neo4j 替换)。有什么办法可以解决这个问题?

  def self.from_omniauth(auth)
    where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
      user.provider = auth.provider
      user.uid = auth.uid
      user.name = auth.info.name
      user.oauth_token = auth.credentials.token
      user.oauth_expires_at = Time.at(auth.credentials.expires_at)
      user.save!
    end
  end
4

1 回答 1

2

gem 确实支持 DateTime!将适当的属性添加到您的模型。

class User
  include Neo4j::ActiveNode
  property :provider
  property :uid
  property :name
  property :oauth_token
  property :auth_expries_at, type: DateTime
end
于 2014-10-20T01:06:02.237 回答