-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
Hello,
I have a collection of Portfolios, with embedded PortfolioItems, with embredded Images.
I want to take Images form PortfolioItem 1 and move them to PortfolioItem 2. Soemhow, I cannot persist that...
Am I doing something wrong here?
ruby-1.9.2-p0 > pf = Portfolio.first
=> #<Portfolio _id: 4cacb9c8681bad776c000014, title: "El Pablo & El Diablo", description: "Mis luchadores mas hermosos", index: 2, meta:
ruby-1.9.2-p0 > it1 = pf.portfolio_items[0]
=> #<PortfolioItem _id: 4cace633681bad7b1e000003, title: "Diablo", description: "###Familienbilder\r\n\r\n\r\n---------
ruby-1.9.2-p0 > it2 = pf.portfolio_items[1]
=> #<PortfolioItem _id: 4cad23fe681bad7f7600000e, title: "Pablo", description: "Isso que é o bonzinho.", date: 2005-01-01 00:00:00 UTC, index: 0>
ruby-1.9.2-p0 > img = it1.images.first
=> #<Image _id: 4cad2155681bad7f7600000b, title: "sdcscds sdsdsd sdvsdvdsv", description: "", technique: "", date: nil, index: 2, image_filename: "p3161721.jpg">
ruby-1.9.2-p0 > it1.images.delete img
=> #<Image _id: 4cad2155681bad7f7600000b, title: "sdcscds sdsdsd sdvsdvdsv", description: "", technique: "", date: nil, index: 2, image_filename: "p3161721.jpg">
ruby-1.9.2-p0 > it2.images << img
=> [#<Image _id: 4cad2155681bad7f7600000b, title: "sdcscds sdsdsd sdvsdvdsv", description: "", technique: "", date: nil, index: 2, image_filename: "p3161721.jpg">]
ruby-1.9.2-p0 > it2.images
=> [#<Image _id: 4cad2416681bad7f76000010, title: "consti im zirkus", description: "", technique: "", date: nil, index: nil, image_filename: "p5300141.jpg">,
#<Image _id: 4cad2447681bad7f76000012, title: "consti alá Truffeaut", description: "", technique: "", date: nil, index: nil, image_filename: "p5300143.jpg">,
#<Image _id: 4cb867ce681bad2dc9000016, title: "testing", description: "", technique: "xxx", date: nil, index: nil, image_filename: "065-teaser.jpg">,
#<Image _id: 4cb888f7681bad331d000002, title: "r2", description: "", technique: "", date: nil, index: nil, image_filename: "061-jms-put-the-needle-on-the-record.jpg">,
*#<Image _id: 4cad2155681bad7f7600000b, title: "sdcscds sdsdsd sdvsdvdsv", description: "", technique: "", date: nil, index: 2, image_filename: "p3161721.jpg">] *
ruby-1.9.2-p0 > it1.images
=> []
ruby-1.9.2-p0 > img.save
=> true
ruby-1.9.2-p0 > it1.save
=> true
ruby-1.9.2-p0 > it2.save
=> true
ruby-1.9.2-p0 > pf.save
=> true
ruby-1.9.2-p0 > quit
~/RubymineProjects/limpens_portfolio_remote/rails_app
>rails c
Loading development environment (Rails 3.0.1)
ruby-1.9.2-p0 > pf = Portfolio.first
=> #<Portfolio _id: 4cacb9c8681bad776c000014, title: "El Pablo & El Diablo", description: "Mis luchadores mas hermosos", index: 2, meta: {"background_color"=>"#0f70ff"}
>
ruby-1.9.2-p0 > it1 = pf.portfolio_items[0]
=> #<PortfolioItem _id: 4cace633681bad7b1e000003, title: "Diablo", description: "###Familienbilder\r\n\r\n\r\n---------\r\n\r\n\r\n---------\r\n\r\n\r\nNur die allerliabsten!", date: 2007-01-01 00:00:00 UTC, index: 1>
ruby-1.9.2-p0 > it2 = pf.portfolio_items[1]
=> #<PortfolioItem _id: 4cad23fe681bad7f7600000e, title: "Pablo", description: "Isso que é o bonzinho.", date: 2005-01-01 00:00:00 UTC, index: 0>
ruby-1.9.2-p0 > it1.images
=> [#<Image _id: 4cad2155681bad7f7600000b, title: "sdcscds sdsdsd sdvsdvdsv", description: "", technique: "", date: nil, index: 2, image_filename: "p3161721.jpg">]
ruby-1.9.2-p0 > it2.images
=> [#<Image _id: 4cad2416681bad7f76000010, title: "consti im zirkus", description: "", technique: "", date: nil, index: nil, image_filename: "p5300141.jpg">,
#<Image _id: 4cad2447681bad7f76000012, title: "consti alá Truffeaut", description: "", technique: "", date: nil, index: nil, image_filename: "p5300143.jpg">,
#<Image _id: 4cb867ce681bad2dc9000016, title: "testing", description: "", technique: "xxx", date: nil, index: nil, image_filename: "065-teaser.jpg">,
#<Image _id: 4cb888f7681bad331d000002, title: "r2", description: "", technique: "", date: nil, index: nil, image_filename: "061-jms-put-the-needle-on-the-record.jpg">]
ruby-1.9.2-p0 >