Forum: Ruby on Rails acts_as_paranoid overrides ActiveRecord::Base??

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.
Konstantin G. (Guest)
on 2006-05-20 05:13
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:in
`validate_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:in
`find_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:in
`method_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:in `output_value'
        from /usr/local/lib/ruby/1.8/irb.rb:151:in `eval_input'
        from /usr/local/lib/ruby/1.8/irb.rb:259:in `signal_status'
        from /usr/local/lib/ruby/1.8/irb.rb:147:in `eval_input'
        from /usr/local/lib/ruby/1.8/irb.rb:146:in `eval_input'
        from /usr/local/lib/ruby/1.8/irb.rb:70:in `start'
        from /usr/local/lib/ruby/1.8/irb.rb:69:in `start'
        from /usr/local/bin/irb:13


Any pointers are welcome!

Thanks,
Konstantin
Rick O. (Guest)
on 2006-05-20 20:51
(Received via mailing list)
> 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:in
> `validate_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...
This topic is locked and can not be replied to.