Class: RailsAdminImageManager::File
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- RailsAdminImageManager::File
- Defined in:
- app/models/rails_admin_image_manager/file.rb
Instance Attribute Summary collapse
-
#src ⇒ Object
Returns the value of attribute src.
-
#src_for_wysiwyg ⇒ Object
Returns the value of attribute src_for_wysiwyg.
Instance Method Summary collapse
- #decode_base64_image ⇒ Object
- #delete_image_folder ⇒ Object
-
#destroy ⇒ Object
To avoid the 500 error when the foreign key constraint fails.
- #tags_list ⇒ Object
Instance Attribute Details
#src ⇒ Object
Returns the value of attribute src.
16 17 18 |
# File 'app/models/rails_admin_image_manager/file.rb', line 16 def src @src end |
#src_for_wysiwyg ⇒ Object
Returns the value of attribute src_for_wysiwyg.
17 18 19 |
# File 'app/models/rails_admin_image_manager/file.rb', line 17 def src_for_wysiwyg @src_for_wysiwyg end |
Instance Method Details
#decode_base64_image ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/models/rails_admin_image_manager/file.rb', line 55 def decode_base64_image if src.present? && src.include?('data:image') new_image = Paperclip.io_adapters.for(src) new_image.original_filename = image_file_name self.image = new_image end end |
#delete_image_folder ⇒ Object
63 64 65 |
# File 'app/models/rails_admin_image_manager/file.rb', line 63 def delete_image_folder FileUtils.rm_rf(::File.dirname(image.path(:original))+'/../') if (self.changes.key?('image_file_name') && self.changes.key?('image_file_size')) end |
#destroy ⇒ Object
To avoid the 500 error when the foreign key constraint fails
47 48 49 50 51 52 53 |
# File 'app/models/rails_admin_image_manager/file.rb', line 47 def destroy begin super rescue return false end end |
#tags_list ⇒ Object
77 78 79 |
# File 'app/models/rails_admin_image_manager/file.rb', line 77 def .collect { |t| t.name } end |