starter question about paperclip / relations in rails 3


i'm trying out Rails 3 and i've created a little app with paperclip.
My problem is that i cant get the assets for a user in the index
action but in the edit action it works. i have the flowing set up

class User
has_many :assets

class Asset
   belongs_to :user
   has_attached_file :asset,
                    :styles => { :medium => "300x300>",
                                 :thumb => "100x100>" }


When you do (user.assets.each do |assetfield|) you are getting each Asset object associated to user in the assetfield variable, but still you need to access the attachment property which is ‘asset’. So basically you just need to change assetfield.url(:thumb) for assetfield.asset.url(:thumb) and it should work fine. Check that this is done in the edit form as asset_fields.object.asset.url(:thumb) (where asset_fields.object represents the same Asset object as assetfield)

Hope this helps. Good luck!


Thank you for taking the time to answer my question and you where
right. just by refering the asset object by
assetfield.asset.url(:thumb) it worked perfect.