1

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
Clam
  • 935
  • 1
  • 12
  • 24

1 Answers1

2

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
subvertallchris
  • 5,282
  • 2
  • 25
  • 43
  • Thanks chris. Was DateTime added into neo4J? Was I right to assume that neo4j datatypes override the old AR ones? I was also trying to understand if timestamps (created_at, updated_at) were automatically created – Clam Oct 20 '14 at 02:06
  • It wasn't. We use the active_attr to provide type conversion of properties, you can check it out and see what it supports. When you save, your Rails properties are converted to datatypes compatible with Neo4j; when you load, they're converted back into what you expect. The exception is Time, which exists in the gem but will actually give you DateTime. – subvertallchris Oct 20 '14 at 02:34