I have an attachment via paperclip and the paperclip with hobo extension. 
 The image gets uploaded fine etc but I'm trying to save the 
image dimensions and the middle point of the image (the mid point is 
used/changed in other parts of the app it just set to the middle of the 
image to initialize it).  I have a method save_image_dimensions that is part 
of the model. It sets 4 attributes but only 3 of the 4 are getting saved to 
the database.  If I debug the code and inspect the self object it has all 
the attributes set properly but if I then check the log file 
the dwg_origin_y value is nil.  Below is the code.  This is very baffling to 
me since 3 of the 4 values get saved just fine.  I've highlighted the 
attribute in the code below that doesn't get saved.

require "pdf_converter.rb"
class Floor < ActiveRecord::Base

  hobo_model # Don't put anything above this
  include ActiveModel::Dirty

  fields do
    name :string, :required
    layout_width :integer
    layout_height :integer
    drawing_scale :float
    dwg_origin_x :float
    *dwg_origin_y :float*
    timestamps
  end

  set_default_order "name DESC"

  has_attached_file :layout, :styles => {:jpg => {:format=>:jpg, 
:rotate=>"270"}}, :processors => [:pdf_converter]
  has_attached_file :csv
  validates_attachment_content_type :csv, :content_type =>
          ['text/csv', 'text/comma-separated-values', 'text/csv', 
'application/csv',
           'application/excel', 'application/vnd.ms-excel', 
'application/vnd.msexcel', 'text/anytext', 'text/plain', 
'application/octet-stream']

  belongs_to :building

  has_many :spaces, :dependent => :destroy

  children :spaces

  after_layout_post_process :save_image_dimensions

  after_save :import_spaces

  def save_image_dimensions
    geo = Paperclip::Geometry.from_file(layout.queued_for_write[:jpg])

    self.layout_width = geo.width
    self.dwg_origin_x = geo.width/2

    self.layout_height = geo.height
   * self.dwg_origin_y  = geo.height/2*

    true
  end

 ....

end

Any hints as to what might be going on here would be appreciated.

Bob

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/hobousers/-/2dhRCmrAcg0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to