# How make attachment\_fu with 2 has\_attachment

**URL:** <https://www.ruby-forum.com/t/how-make-attachment-fu-with-2-has-attachment/158423>\
**Category:** Rails\
**Created:** [January 23, 2009, 5:43am UTC](https://www.ruby-forum.com/t/how-make-attachment-fu-with-2-has-attachment/158423 "2009-01-23T05:43:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anton\_effendi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@anton\_effendi](https://www.ruby-forum.com/u/anton_effendi)\
**Post date:** [January 23, 2009, 5:43am UTC](https://www.ruby-forum.com/t/how-make-attachment-fu-with-2-has-attachment/158423/1 "2009-01-23T05:43:24Z")

</div>

Hiii  
I need help…  
I want to make upload photo with attachment\_fu…

this logic is  
if admin

has\_attachment :content\_type =\> :image,  
:storage =\> :file\_system,  
:path\_prefix =\> ‘public/photos’,  
:processor =\> ‘Rmagick’,  
:thumbnails =\> {:standard =\> “520x520\>”, _:thumb =\>  
“110x110\>”_, :medium =\> “250x250\>”},  
:size =\> 0.kilobytes…5000.kilobytes

if user  
has\_attachment :content\_type =\> :image,  
:storage =\> :file\_system,  
:path\_prefix =\> ‘public/photos’,  
:processor =\> ‘Rmagick’,  
:thumbnails =\> {:standard =\> “520x520\>”, _:thumb =\>  
“120x120\>”_, :medium =\> “250x250\>”},  
:size =\> 0.kilobytes…5000.kilobytes

I want to make it in 1 model… because I save to 1 table…

Any body can help me?  
Thank you

–  
Wu You Duan

---

<div class="post-metadata">

**Author:** ![anton\_effendi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@anton\_effendi](https://www.ruby-forum.com/u/anton_effendi)\
**Post date:** [January 23, 2009, 10:45am UTC](https://www.ruby-forum.com/t/how-make-attachment-fu-with-2-has-attachment/158423/2 "2009-01-23T10:45:45Z")

</div>

anton effendi wrote:

> “110x110\>”\*, :medium =\> “250x250\>”},  
> :size =\> 0.kilobytes…5000.kilobytes
> 
> I want to make it in 1 model… because I save to 1 table…

Put these in Admin and OrdinaryUser sub-classes/sub-models of your  
main User model. If you add an STI “type” field to this model then  
both these models will still use the users table if you properly  
instantiate them.

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)

---

<div class="post-metadata">

**Author:** ![anton\_effendi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@anton\_effendi](https://www.ruby-forum.com/u/anton_effendi)\
**Post date:** [January 23, 2009, 3:47pm UTC](https://www.ruby-forum.com/t/how-make-attachment-fu-with-2-has-attachment/158423/3 "2009-01-23T15:47:18Z")

</div>

Thank you…  
Your ide must use 3 model… 1 model → User, 1 model → for admin, 1  
model  
 → for user  
is true?  
But I want use 1 model for admin and user…  
so if I call “user = User.create” in admin and in user, photo will  
upload…  
with different size thumbnail.

Can u explain with code?? thank you very much

On Fri, Jan 23, 2009 at 4:44 PM, Mark Reginald J.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > ```
> > :path_prefix => 'public/photos',
> > :processor => 'Rmagick',
> > 
> > ```
> 
> instantiate them.
> 
> –  
> Rails Wheels - Find Plugins, List & Sell Plugins - [http://railswheels.com](http://railswheels.com)
> 
> >

–  
Wu You Duan

---

<div class="post-metadata">

**Author:** ![anton\_effendi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@anton\_effendi](https://www.ruby-forum.com/u/anton_effendi)\
**Post date:** [January 25, 2009, 5:01am UTC](https://www.ruby-forum.com/t/how-make-attachment-fu-with-2-has-attachment/158423/4 "2009-01-25T05:01:28Z")

</div>

anton effendi wrote:

> Thank you…  
> Your ide must use 3 model… 1 model → User, 1 model → for admin, 1  
> model → for user  
> is true?  
> But I want use 1 model for admin and user…  
> so if I call “user = User.create” in admin and in user, photo will  
> upload… with different size thumbnail.
> 
> Can u explain with code?? thank you very much

class User \< ActiveRecord::Base

# Database table “users”, having string field “type”

# Put methods common to all users here

end

class OrdinaryUser \< User  
has\_attachment :thumbnails =\> …  
end

class Admin \< User  
has\_attachment :thumbnails =\> …  
end

user = OrdinaryUser.create!  
admin = Admin.create!

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)
