Module: Mongoid::Paperclip::ClassMethods
- Defined in:
- lib/mongoid_paperclip.rb
Instance Method Summary collapse
-
#has_attached_file(field, options = {}) ⇒ Object
This method is deprecated.
-
#has_mongoid_attached_file(field, options = {}) ⇒ Object
Adds Mongoid::Paperclip’s “#has_mongoid_attached_file” class method to the model which includes Paperclip and Paperclip::Glue in to the model.
Instance Method Details
#has_attached_file(field, options = {}) ⇒ Object
This method is deprecated
82 83 84 85 |
# File 'lib/mongoid_paperclip.rb', line 82 def has_attached_file(field, = {}) raise "Mongoid::Paperclip#has_attached_file is deprecated, " + "Use 'has_mongoid_attached_file' instead" end |
#has_mongoid_attached_file(field, options = {}) ⇒ Object
Adds Mongoid::Paperclip’s “#has_mongoid_attached_file” class method to the model which includes Paperclip and Paperclip::Glue in to the model. Additionally it’ll also add the required fields for Paperclip since MongoDB is schemaless and doesn’t have migrations.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/mongoid_paperclip.rb', line 58 def has_mongoid_attached_file(field, = {}) ## # Include Paperclip and Paperclip::Glue for compatibility unless self.ancestors.include?(::Paperclip) include ::Paperclip include ::Paperclip::Glue end ## # Invoke Paperclip's #has_attached_file method and passes in the # arguments specified by the user that invoked Mongoid::Paperclip#has_mongoid_attached_file has_attached_file(field, ) ## # Define the necessary collection fields in Mongoid for Paperclip field(:"#{field}_file_name", :type => String) field(:"#{field}_content_type", :type => String) field(:"#{field}_file_size", :type => Integer) field(:"#{field}_updated_at", :type => DateTime) end |