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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2009-Jan-23 09:44 UTC
Re: how make attachment_fu with 2 has_attachment
anton effendi wrote:> 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...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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 James <mrj-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org>wrote:> > anton effendi wrote: > > > 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... > > 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 > > > >-- Wu You Duan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2009-Jan-25 04:00 UTC
Re: how make attachment_fu with 2 has_attachment
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 muchclass 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---