Created
November 9, 2010 17:53
-
-
Save jblanche/669487 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DragonFly makes image handling with Rails3 easy but you must have one and only one image per field | |
# but what if I want to display a Gallery of places photos ? | |
# Is there a way to do something like this ? Where I could have only one image for a place and maybe ten for another one ? | |
class Place | |
include Mongoid::Document | |
images_accessor :place_images #Note the final S : imageS_accessor | |
# This I would like to avoid | |
# image_accessor :place_image_1 | |
# image_accessor :place_image_2 | |
# image_accessor :place_image_3 | |
# image_accessor :place_image_4 | |
# image_accessor :place_image_5 | |
# (...) | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Iterate over the images and show them | |
<% @place.place_images.each do |place_image| %> | |
<%= image_tag place_image.url %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment