# Attachment\_fu, minimum width and height, how?

**URL:** <https://www.ruby-forum.com/t/attachment-fu-minimum-width-and-height-how/142046>\
**Category:** Rails\
**Created:** [July 2, 2008, 10:02pm UTC](https://www.ruby-forum.com/t/attachment-fu-minimum-width-and-height-how/142046 "2008-07-02T22:02:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [July 2, 2008, 10:02pm UTC](https://www.ruby-forum.com/t/attachment-fu-minimum-width-and-height-how/142046/1 "2008-07-02T22:02:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [July 3, 2008, 9:47am UTC](https://www.ruby-forum.com/t/attachment-fu-minimum-width-and-height-how/142046/2 "2008-07-03T09:47:33Z")

</div>

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 🙂
