Module: Watarase::Controller::InstanceMethods
- Defined in:
- lib/watarase/controller.rb
Instance Method Summary collapse
- #expire_caches ⇒ Object
- #image_data_path(model) ⇒ Object
- #image_handler ⇒ Object
- #image_holder ⇒ Object
- #image_params ⇒ Object
- #image_thumb_path(model) ⇒ Object
- #load_image ⇒ Object
Instance Method Details
#expire_caches ⇒ Object
29 30 31 |
# File 'lib/watarase/controller.rb', line 29 def expire_caches expire_action action: :load_image end |
#image_data_path(model) ⇒ Object
51 52 53 |
# File 'lib/watarase/controller.rb', line 51 def image_data_path(model) url_for(controller: image_handler.name.downcase!.pluralize, action: 'load_image', id: model.send(:"#{image_holder.name.underscore}").id, image_column: :image_data) end |
#image_handler ⇒ Object
39 40 41 |
# File 'lib/watarase/controller.rb', line 39 def image_handler self.class.class_variable_get(:@@image_handler) end |
#image_holder ⇒ Object
43 44 45 |
# File 'lib/watarase/controller.rb', line 43 def image_holder "#{image_handler.name.underscore}_#{Watarase.suffix}".camelize.constantize end |
#image_params ⇒ Object
33 34 35 36 37 |
# File 'lib/watarase/controller.rb', line 33 def image_params ip = params.require(image_handler.name.underscore.to_sym).permit(:image_file, :remove_image) puts "**** image_params **** #{ip} ****" Thread.current[:image_params] = ip end |
#image_thumb_path(model) ⇒ Object
47 48 49 |
# File 'lib/watarase/controller.rb', line 47 def image_thumb_path(model) url_for(controller: image_handler.name.downcase!.pluralize, action: 'load_image', id: model.send(:"#{image_holder.name.underscore}").id, image_column: :image_thumb) end |
#load_image ⇒ Object
23 24 25 26 27 |
# File 'lib/watarase/controller.rb', line 23 def load_image image = image_holder.find(params[:id]) column_name = :"#{(params[:image_column] || 'image_data')}" send_data image.send(column_name), type: image.content_type, disposition: 'inline' end |