Permalink
Browse files

Replaced skip_callback with conditional callback

  • Loading branch information...
1 parent 3d18cdc commit 511bb2ad7f5e61b87d2207e16ea9b2408ced2471 @mischa78 mischa78 committed Apr 18, 2011
Showing with 3 additions and 4 deletions.
  1. +3 −4 app/models/folder.rb
View
7 app/models/folder.rb
@@ -4,19 +4,18 @@ class Folder < ActiveRecord::Base
has_many :user_files, :dependent => :destroy, :order => 'attachment_file_name'
has_many :permissions, :dependent => :destroy
+ attr_accessor :is_copied_folder
attr_accessible :name, :user_id
validates_uniqueness_of :name, :scope => :parent_id
validates_presence_of :name
before_save :check_for_parent
- after_create :create_permissions
+ after_create :create_permissions, :unless => :is_copied_folder
def copy(target_folder, originally_copied_folder = nil)
- # We skip callback, because we need original permissions, not parent's
- Folder.skip_callback(:create, :after, :create_permissions)
-
new_folder = self.clone
+ new_folder.is_copied_folder = true
new_folder.parent = target_folder
new_folder.save!

0 comments on commit 511bb2a

Please sign in to comment.