Forum: Ruby on Rails acts_as_paranoid and nested scopes in Rails 1.1

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dave (Guest)
on 2006-05-11 13:58
I have a real problem with the acts_as_paranoid plugin. The find-scope
nesting does not seem to work at all.

The description:
I made a copy of 'acts_as_paranoid' in the plugin directory, renamed it
to 'acts_as_very_new'(just nonsense plugin for testing), and just
simplified the code:
#--------------------------------------------------------------
 module VeryNew
 #...
   module ClassMethods
     def acts_as_very_new
       unless is_very_new? # don't let AR call this twice
         class << self
           alias_method :find_with_old,  :find
         end
       end
       include InstanceMethods
     end

#   end

   module InstanceMethods #:nodoc:
     def self.included(base) # :nodoc:
       base.extend ClassMethods
     end

     module ClassMethods
       def find(*args)
         with_very_new_scope { find_with_old(*args) }
       end

       protected
         def with_very_new_scope(&block)
           with_scope({:find => {:conditions =>
["#{table_name}.updated_at > ?", (Time.new - 3.days)]} }, :merge,
&block)
         end
     end

   end
 end
Dave (Guest)
on 2006-05-11 14:19
Sorry, I accidentally pushed the "ENTER" button. Please ignore that one
and read http://www.ruby-forum.com/topic/65372#new!

Thanks
This topic is locked and can not be replied to.