I use Rails 3 and Carrierwave. I have two models: Gallery and GalleryPicture :
class Gallery < ActiveRecord::Base has_many :gallery_pictures end class GalleryPicture < ActiveRecord::Base belongs_to :gallery mount_uploader :gallery_pic, GalleryUploader end
How can I save image and gallery? The following snapshot does not save:
gallery = params[:gallery].delete(:gallery_pic) @gallery = Gallery.new(params[:gallery]) @gallery.gallery_pictures << GalleryPicture.new(gallery) @gallery.save
source share