Class: RailsAdminImageManager::File

Inherits:
ApplicationRecord show all
Defined in:
app/models/rails_admin_image_manager/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#srcObject

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_wysiwygObject

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_imageObject



51
52
53
54
55
56
57
# File 'app/models/rails_admin_image_manager/file.rb', line 51

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

#destroyObject

To avoid the 500 error when the foreign key constraint fails



43
44
45
46
47
48
49
# File 'app/models/rails_admin_image_manager/file.rb', line 43

def destroy
  begin
    super
  rescue
    return false
  end
end

#tags_listObject



69
70
71
# File 'app/models/rails_admin_image_manager/file.rb', line 69

def tags_list
  tags.collect { |t| t.name }
end