-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
class Folder include Mongoid::Document include Mongoid::Paranoia field :name, :type => String has_many :folder_items end class FolderItem include Mongoid::Document include Mongoid::Paranoia belongs_to :folder field :name, :type => String validates :name, :uniqueness => {:scope => :folder_id, :message => 'buyaaa', :case_sensitive => false} end fun = Folder.create(:name => 'Entertainment') work = Folder.create(:name => 'Work') music = FolderItem.create(:name => 'Music', :folder_id => fun.id) movie = FolderItem.new(:name => 'Movies', :folder_id => fun.id) movie.valid? movie.save movie.delete movie = FolderItem.new(:name => 'Movies', :folder_id => fun.id) movie.valid? # MONGODB (0ms) cloudfactory_development['$cmd'].find({"count"=>"folder_items", "query"=>{:name=>"Movies", :folder_id=>BSON::ObjectId('4feafbaa6f90cb295200001e')}, "fields"=>nil}).limit(-1) => false
As you can see, there's no deleted query (as it should be accompanied with Paranoia) fired along the last line and we can't create movie once it's deleted in the same folder.