Yesterday I was using attachment_fu to attach photos to a couple of models. Since attachment_fu requires you to create an extra model for the photo, you usually have a one to one relationship between the model and the photo.
But now that you have two models you also have to deal with these in your controller and views, something along the lines of this:
Sort of ugly if all you want is to add a photo to the Project model. But fear not, after adding the following piece of code to your model, you can transparently assign the photo to your project model in the view:
The tweaked model:
Now you can use a standard view:
And a standard controller:
(credits to this railscast for the idea of using a virtual attribute, I only added a bit of sugar for attachment_fu)
You’ve found our very old Website Archive (2007-2012). It’s a bit out of date, but we love looking back at how it all started - and how far we’ve come since then!
We’re now fully focused on building our coworking management product, Cobot.