I might be missing something silly but I can't get multiple embedded photo files into a form
Models
class Product
include Mongoid::Document
embeds_many :photos, cascade_callbacks: true
end
class Photo
include Mongoid::Document
embedded_in product, :inverse_of => :photos
field :image_filename
mount_uploader :image, ImageUploader
end
Controller - products_controller.rb
def new
@product = Product.new
3.times { @product.photos.build }
end
Form
Then I do the form with
fields_for @product.photos do |photo|
<%= photo.file_field :image %>
end
The problem is only 1 photo is showing up but I am building 3 in the controller. The count for @product.photos.count is 0 even after i build 3 in memory. Am I missing something?