Module: Neo4jrb
- Defined in:
- lib/neo4jrb_paperclip.rb
Overview
The Neo4jrb::Paperclip extension Makes Paperclip play nice with the Neo4j Models
Example:
class User
include Neo4j::ActiveNode
include Neo4jrb::Paperclip
has_neo4jrb_attached_file :avatar
:avatar, content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"]
end
The above example is all you need to do. This will load the Paperclip library into the User model and add the “has_neo4jrb_attached_file” class method. Provide this method with the same values as you would when using “vanilla Paperclip”. The first parameter is a symbol [:field] and the second parameter is a hash of options [options = {}]. Note that the validation must come after the call to :has_neo4jrb_attached_file.
Unlike Paperclip for ActiveRecord, since MongoDB does not use “schema” or “migrations”, Neo4jrb::Paperclip automatically adds the neccesary “fields” to your Model (MongoDB collection) when you invoke the “#has_neo4jrb_attached_file” method. When you invoke “has_neo4jrb_attached_file :avatar” it will automatially add the following fields:
field :avatar_file_name, :type => String
field :avatar_content_type, :type => String
field :avatar_file_size, :type => Fixnum
field :avatar_updated_at, :type => DateTime
Defined Under Namespace
Modules: Paperclip