no ideas why collection saving isn't working...
This commit is contained in:
parent
1bd2c16ef1
commit
51fd87db36
3 changed files with 20 additions and 3 deletions
|
|
@ -4,10 +4,8 @@ class Collection
|
||||||
key :name, String
|
key :name, String
|
||||||
|
|
||||||
belongs_to :person, :class_name => 'Person'
|
belongs_to :person, :class_name => 'Person'
|
||||||
|
many :photos, :class_name => 'Photo', :foreign_key => :collection_id
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
|
|
||||||
#many :posts, :class_name => 'Post', :foreign_key => :collection_id
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,8 @@ class Photo < Post
|
||||||
require 'carrierwave/orm/mongomapper'
|
require 'carrierwave/orm/mongomapper'
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
mount_uploader :image, ImageUploader
|
mount_uploader :image, ImageUploader
|
||||||
|
|
||||||
|
key :collection_id, ObjectId
|
||||||
|
|
||||||
|
belongs_to :collection, :class_name => 'Collection'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,22 @@ describe Collection do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should contain photos' do
|
it 'should contain photos' do
|
||||||
|
collection = Collection.create(:name => "test collection")
|
||||||
|
|
||||||
|
|
||||||
|
photo = Photo.create(:person => @user)
|
||||||
|
|
||||||
|
puts photo.valid?
|
||||||
|
puts collection.valid?
|
||||||
|
|
||||||
|
puts photo.inspect
|
||||||
|
puts collection.photos.inspect
|
||||||
|
|
||||||
|
puts 'asdojasd'
|
||||||
|
puts photo.collection
|
||||||
|
puts 'asdojasd'
|
||||||
|
|
||||||
|
collection.photos.count.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue