Well I'm stuck again. And this time, maybe it's because I'm using a tool in a way for which it was not designed.
I am using Paperclip for image attachments, and I'm saving these images as instances of a model called, you guessed it, Image. Images belong to users. Users have many images.
However, I want to specify ONE of the user's images as their default image. So, my brain tells me that I need to add a field to the User table to hold the ID of the image I want to be the default.
Images use has_attached_file. I don't want users to have their own attached file, I just want the user model to be able to reference a specific instance of an image that has the url helper methods available to it.
The problem comes in when I'm trying to get the URL for this image using the ID. Either what I'm trying to do is impossible using paperclip, or I don't have my associations set up correctly.
Basically I want to be able to access that image in a view, using an instance of a user model. So:
<%= image_tag @user.image.url %>
But this doesn't work. I get why it doesn't work, but I don't understand how to make
@user.image
be an instance of a magical paperclip object that has the methods attached to it to retrieve the url.
Basically if I knew how to get a paperclip image's URL using the images ID i'd be golden. Any clues?