I have a polymorphic Attachment model to save images uploaded by users. Users can set any of their own as a profile pic.
To this, I created an "avatar_id" column in the User database to basically save the attachment id to create the reference. I also added an avatar action to the User model:
def avatar
self.attachments.first(:conditions => ['id = ?', self.avatar_id])
end
The problem is that if I try to make this work
<%= @user.avatar.url %>
It doesn't work because the url method doesn't exist. I need to specify that is an paperclip object but I don't get where and how I should do it. I'm probably missing something obviously here.