A: 

Something like this in the url:

:url => "/attachments/:path/:basename_:style.:extension",  

then in the interpolations:

Paperclip.interpolates :path do |attachment, style|
  if attachment.instance.file_owner_type == User.class.name
    # first set the _user variable (something like self.owner.id.to_s) 
    return "user_" + _user
  else
    # first set the _user, _dressing, _garmet, _category variables from your models
    return "user_#{_user}/dressing_#{_dressing}/garment_#{_garmet}/category_#{_category}/"
  end
end

Notice that you need to set the _user, _dressing, _garmet, _category variables from your models.

Hope this helps.

cristian
Thx but I already have interpolations that works well.I have an asset model that is polymorphic, the owner can be a user (for is avatar), a garment or a dressing. And I want to have a different path depending on the file owner.At this time, when I want to add a garment asset it works well the picture is put in "/attachments/user_x/dressing_y/garment_z/category_u/something_style.jpg" but if I just want a user picture this path will put the avatar in "/attachments/user_x/dressing_/garment_/category_/something_style.jpg" whereas I want to put it in "/attachments/user_x/something_style.jpg".
guts
I've changed my answer according to the clarifications in the question.
cristian
A: 

I think this might work. Just try it. :D

class Asset < ActiveRecord::Base

  belongs_to :file_owner, :polymorphic => true

  owner = self.file_owner.to_s #get the file owner type and save it in a variable

  has_attached_file :picture, :styles => { ...},
             :url => "/attachments/" + owner + "/:basename_:style.:extension",  
             :path => ":rails_root/public/attachments/" + owner + "/:basename_:style.:extension"  
end
Rohit
That won't work because `has_attached_file` is evaluated at class load time (not object initialization time). You need to evaluate 'owner' for every instance of Asset.
Ariejan
@Ariejan I have done it in my project and it works perfectly. You just try and run the code and see for yourself
Rohit
A: 

Try: attachment.instance.file_owner.class.downcase in your defined interpolation.

Ariejan