Class: Spina::Attachment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spina/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_destroyObject

Returns the value of attribute _destroy.



7
8
9
# File 'app/models/spina/attachment.rb', line 7

def _destroy
  @_destroy
end

Instance Method Details

#nameObject



14
15
16
# File 'app/models/spina/attachment.rb', line 14

def name
  file.file.try(:filename)
end

#old_update_attributesObject



18
# File 'app/models/spina/attachment.rb', line 18

alias_method :old_update_attributes, :update_attributes

#update_attributes(attributes) ⇒ Object



19
20
21
22
23
24
25
# File 'app/models/spina/attachment.rb', line 19

def update_attributes(attributes)
  if attributes["_destroy"] == "1" && attributes["file"].blank?
    self.page_part.destroy
  else
    old_update_attributes(attributes)
  end
end