9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb', line 9
def self.generate_delete_helper(klass, field)
klass.class_eval " attr_reader :delete_\#{field}\n \n def delete_\#{field}=(value)\n value = (value == \"true\") if String === value\n return unless value\n \n # passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!\n self.\#{field} = nil unless self.\#{field}.dirty?\n end\n EOF\nend\n", __FILE__, __LINE__ + 1 unless klass.methods.include?("delete_#{field}=")
|