Note that there are some explanatory texts on larger screens.

plurals
  1. POCarrierwave getting image width and height and storing it in an hstore field
    primarykey
    data
    text
    <p>My FileHandler model can allows all types of files</p> <pre><code>class FileHandler &lt; ActiveRecord::Base serialize :properties, ActiveRecord::Coders::Hstore mount_uploader :file_path, FileUploader //I'm already setting some of the file attributes here def update_file_attributes if file_path.present? &amp;&amp; file_path_changed? self.file_name = file_path.file.filename self.file_type = file_path.file.content_type self.file_size = file_path.file.size end end //I want to get height and width here #Hstore %w[ImageHeight ImageWidth].each do |key| attr_accessible key define_method(key) do properties &amp;&amp; properties[key] end define_method("#{key}=") do |value| self.properties = (properties || {}).merge(key =&gt; value) end end </code></pre> <p>And my fileUploader class</p> <pre><code>class FileUploader &lt; CarrierWave::Uploader::Base # Include RMagick or MiniMagick support: include CarrierWave::RMagick version :big, :if =&gt; :image? do process :resize_to_limit =&gt; [760, nil] end version :thumb_big, :if =&gt; :image? do process :resize_to_limit =&gt; [200, 200] end version :thumb, :if =&gt; :image? do process :resize_to_limit =&gt; [160, 160] end version :tiny, :if =&gt; :image? do process :resize_to_limit =&gt; [40, 40] end protected def image?(new_file) new_file.content_type.include? 'image' end end </code></pre> <p>My question is, how do i get the height and width property of the original image and store it in the hstore field? Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload