Module: Attacheable::ClassMethods
- Defined in:
- lib/attacheable.rb
Instance Method Summary collapse
-
#data_by_path_info(path_info) ⇒ Object
It is designed to read params, or splitted PATH_INFO in mongrel handler It assumes, that path_info is of the following format [“0000”, “0001”, “file_medium.jpg”].
-
#regenerate_thumbnails!(thumbnail = nil) ⇒ Object
You can delete all thumbnails or with selected type.
Instance Method Details
#data_by_path_info(path_info) ⇒ Object
It is designed to read params, or splitted PATH_INFO in mongrel handler It assumes, that path_info is of the following format [“0000”, “0001”, “file_medium.jpg”]
105 106 107 108 109 110 111 112 113 |
# File 'lib/attacheable.rb', line 105 def data_by_path_info(path_info) id1, id2, path = path_info return [nil, nil] unless id1 && id2 && path object = find(id1.to_i*1000 + id2.to_i) if path = object.full_filename_by_path(path) return [object, File.read(path)] if File.exists?(path) end [object, nil] end |
#regenerate_thumbnails!(thumbnail = nil) ⇒ Object
You can delete all thumbnails or with selected type
95 96 97 98 99 100 |
# File 'lib/attacheable.rb', line 95 def regenerate_thumbnails!(thumbnail = nil) connection.select_values("select id from #{table_name}").each do |object_id| object = find_by_id(object_id) object.destroy_thumbnails!(thumbnail) end end |