Attachment_fu, minimum width and height, how?

Hi guys, i’m using attachment_fu for uploading images, but i’ve to check
that the width and the height are at least 200px, how can i do this?
i’ve tried to do a validate errors.add(:width, ‘’) if
self.parent_id.nil? and self.width < 200, but this doesn’t work, both
the width and height are nil, so i think that them are set after the
validation
thanks

There are hooks for after create and after save (and update,
destroy…etc)

just implement a method that is called after_create and put your
validation there, you can revert chanegs if your size is incorrect.
There is another way. validations in models allow the :on key like
validate :correct_size :on => :create

def correct-size
errors.add…
end

i might be completely on another topic though :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs