11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/griddle/has_grid_attachment.rb', line 11
def has_grid_attachment name, options = {}
write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
attachment_definitions[name] = options
after_save :save_attached_files if respond_to? :after_save
after_destroy :destroy_attached_files if respond_to? :after_destroy
define_method(name) do |*args|
attachment_for(name, options)
end
define_method("#{name}=") do |file|
attachment_for(name, options).assign(file)
end
end
|