Search code examples
ruby-on-railsrubyneo4jfacebook-oauthneo4j.rb

Neo4J gem datetime datatype


I'm using a combination of code from

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

oauth portion and trying to integrate it with neo4J

https://github.com/neo4jrb/neo4j

As far as I know this gem replaces many active record pieces, including the datatypes.

I am trying to replace this block of code. They have their oauth_expires_at set as a datetime data type which I don't believe the neo4j gem has (I am assuming I can't use datetype because active record is replaced by neo4j in this case). What might be some options to deal with this?

  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

Solution

  • The gem does support DateTime! Add the appropriate properties to your model.

    class User
      include Neo4j::ActiveNode
      property :provider
      property :uid
      property :name
      property :oauth_token
      property :auth_expries_at, type: DateTime
    end