Acts_as_paranoid overrides ActiveRecord::Base?


#1

Guys,

I am trying to figure out what exactly does this line do at the end of
“acts_as_paranoid” plugin?

ActiveRecord::Base.send :include, Caboose::Acts::Paranoid::ActiveRecord

My problem: I have some classes that I use acts_as_paranoid, and others
with tagging support. Classes declared as taggable, throw error, which
appears to be in the acts_as_paranoid version of the “find” method,
however it’s not supposed to override Base for this class at all (this
particular class is not “paranoid”). So it looks like just having
“acts_as_paranaoid.rb” in my lib directory overrides Base for all cases,
hence my suspicion about the above line…

b = Book.find(1)
=> #<Book:0x277bff4 @attributes={“date_published”=>nil,
“dimensions”=>nil, “title”=>“Title”, “id”=>“1”, “subtitle”=>nil,
“pages”=>“343”, “author_description”=>nil}>

b.tags
ArgumentError: Unknown key(s): from
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/core_ext/hash/keys.rb:48:in
assert_valid_keys' from ./script/../config/../config/../lib/acts_as_paranoid.rb:66:invalidate_find_options’
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:376:in
find' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/associations/has_many_through_association.rb:54:infind_target’
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/associations/association_proxy.rb:116:in
load_target' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/associations/association_proxy.rb:109:inmethod_missing’
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/associations/has_many_through_association.rb:47:in
method_missing' from /usr/local/lib/ruby/1.8/irb.rb:298:inoutput_value’
from /usr/local/lib/ruby/1.8/irb.rb:151:in eval_input' from /usr/local/lib/ruby/1.8/irb.rb:259:insignal_status’
from /usr/local/lib/ruby/1.8/irb.rb:147:in eval_input' from /usr/local/lib/ruby/1.8/irb.rb:146:ineval_input’
from /usr/local/lib/ruby/1.8/irb.rb:70:in start' from /usr/local/lib/ruby/1.8/irb.rb:69:instart’
from /usr/local/bin/irb:13

Any pointers are welcome!

Thanks,
Konstantin


#2

I am trying to figure out what exactly does this line do at the end of
“acts_as_paranoid” plugin?

ActiveRecord::Base.send :include, Caboose::Acts::Paranoid::ActiveRecord

That adds the paranoid mixin to AR::Base.

Here’s your error message…

ArgumentError: Unknown key(s): from
from

from:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/core_ext/hash/keys.rb:48:in

assert_valid_keys' from ./script/../config/../config/../lib/acts_as_paranoid.rb:66:invalidate_find_options’

Try updating acts as paranoid:

(notice there’s no validate_find_options method call in the latest)

http://svn.techno-weenie.net/projects/plugins/acts_as_paranoid/lib/caboose/acts/paranoid.rb