Class: Boxroom::UserFile
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Boxroom::UserFile
show all
- Defined in:
- app/models/boxroom/user_file.rb,
app/concepts/boxroom/user_file/operations/notify_create.rb,
app/concepts/boxroom/user_file/operations/notify_remove.rb,
app/concepts/boxroom/user_file/operations/notify_update.rb
Defined Under Namespace
Modules: Contract
Classes: NotifyCreate, NotifyRemove, NotifyUpdate
Instance Method Summary
collapse
Instance Method Details
#copy(target_folder) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/models/boxroom/user_file.rb', line 14
def copy(target_folder)
new_file = self.dup
new_file.folder = target_folder
new_file.save!
path = "#{Rails.root}/#{Boxroom.configuration.uploads_path}/#{Rails.env}/#{new_file.id}/original"
FileUtils.mkdir_p path
FileUtils.cp_r self.attachment.path, "#{path}/#{new_file.id}"
new_file
end
|
#extension ⇒ Object
32
33
34
|
# File 'app/models/boxroom/user_file.rb', line 32
def extension
File.extname(attachment_file_name)[1..-1]
end
|
#move(target_folder) ⇒ Object
27
28
29
30
|
# File 'app/models/boxroom/user_file.rb', line 27
def move(target_folder)
self.folder = target_folder
save!
end
|