deleting tar for products on update
This commit is contained in:
parent
87845c3ac9
commit
055dfe665d
|
@ -16,10 +16,26 @@ class Product < ActiveRecord::Base
|
||||||
|
|
||||||
scope :recent, order("name ASC")
|
scope :recent, order("name ASC")
|
||||||
|
|
||||||
|
before_save :destroy_tar?
|
||||||
|
|
||||||
|
def delete_tar
|
||||||
|
@delete_tar ||= "0"
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_tar=(value)
|
||||||
|
@delete_tar = value
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def destroy_tar?
|
||||||
|
self.tar.clear if @delete_tar == "1"
|
||||||
|
end
|
||||||
|
|
||||||
def merge_tar_errors
|
def merge_tar_errors
|
||||||
errors[:tar] += errors[:tar_content_type]
|
errors[:tar] += errors[:tar_content_type]
|
||||||
errors[:tar_content_type] = []
|
errors[:tar_content_type] = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,8 +14,14 @@
|
||||||
= f.label :menu, t("activerecord.attributes.product.menu"), :class => :label
|
= f.label :menu, t("activerecord.attributes.product.menu"), :class => :label
|
||||||
= f.text_area :menu, :class => 'text_field', :cols => 80
|
= f.text_area :menu, :class => 'text_field', :cols => 80
|
||||||
.group
|
.group
|
||||||
|
%p
|
||||||
= f.label :tar, t("activerecord.attributes.product.tar"), :class => :label
|
= f.label :tar, t("activerecord.attributes.product.tar"), :class => :label
|
||||||
= f.file_field :tar, :class => 'file_field'
|
= f.file_field :tar, :class => 'file_field'
|
||||||
|
%p
|
||||||
|
- if @product.tar?
|
||||||
|
= link_to @product.tar_file_name, @product.tar.url
|
||||||
|
= f.check_box :delete_tar
|
||||||
|
= f.label :delete_tar, t('layout.delete')
|
||||||
|
|
||||||
.group.navform.wat-cf
|
.group.navform.wat-cf
|
||||||
%button.button{:type => "submit"}
|
%button.button{:type => "submit"}
|
||||||
|
|
Loading…
Reference in New Issue