Problem with acts_as_paranoid: "ArgumentError: Unknown key(s

Here’s the full error:

  1. Error:
    test_add_message_to_existing_ticket(TicketTest):
    ArgumentError: Unknown key(s): group
    /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.4/lib/active_support/core_ext/hash/keys.rb:48:in
    assert_valid_keys' /usr/lib/ruby/gems/1.8/gems/acts_as_paranoid-0.2/lib/acts_as_paranoid.rb:125:invalidate_find_options’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/base.rb:1164:in
    extract_options_from_args!' /usr/lib/ruby/gems/1.8/gems/acts_as_paranoid-0.2/lib/acts_as_paranoid.rb:62:infind’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/associations/has_many_association.rb:111:in
    find_target' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/associations/association_proxy.rb:81:inload_target’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/associations/association_collection.rb:20:in
    <<' ./test/unit/ticket_test.rb:62:intest_add_message_to_existing_ticket’

The code in question:
t.messages << Message.new({ :body => “ya message body”, :user =>
users(:bob) })

t is a Ticket object, and a Ticket has_many :messages. Both Ticket
and Message mixin acts_as_paranoid. I also get the same error if I
call Ticket#destroy.

I think this may have been asked on the list already, but I can’t find
anything in gmane, ruby-forum, or google so I’m lost.

Pat

Pat M. wrote:

  1. Error:
    test_add_message_to_existing_ticket(TicketTest):
    ArgumentError: Unknown key(s): group

anything in gmane, ruby-forum, or google so I’m lost.
I just ran into this same problem. You need to edit acts_as_paranoid.rb.
In the validate_find_options method (line 125) add the symbol :group.

Here’s how the method originally appears:

def validate_find_options(options)
options.assert_valid_keys [:conditions, :include, :joins, :limit, :
offset, :order, :select, :readonly, :with_deleted]
end

and here is the edited version:

def validate_find_options(options)
options.assert_valid_keys [:conditions, :include, :joins, :limit, :
offset, :order, :select, :readonly, :group, :with_deleted]
end

Ideally I suppose acts_as_paranoid would somehow figure out the keys
that ActiveRecord finds acceptable, then append :with_deleted on to the
lsit, but I don’t know how one would do that.

Someone already submitted a patch to fix this problem here:

http://rubyforge.org/tracker/index.php?func=detail&aid=2870&group_id=944&atid=3711

-F

and here is the edited version:
Someone already submitted a patch to fix this problem here:

http://rubyforge.org/tracker/index.php?func=detail&aid=2870&group_id=944&atid=3711

It’s in SVN along with a few more additions. I’m just waiting for
Rails 1.0 so I can release aap v0.3 and piggy back on the tidal wave
of interest.

http://techno-weenie.net/svn/projects/plugins/acts_as_paranoid

Someday I’ll probably move that to RubyForge’s SVN repo too.


rick
http://techno-weenie.net

Rick O. wrote:

It’s in SVN along with a few more additions. I’m just waiting for
Rails 1.0 so I can release aap v0.3 and piggy back on the tidal wave
of interest.

http://techno-weenie.net/svn/projects/plugins/acts_as_paranoid

Someday I’ll probably move that to RubyForge’s SVN repo too.

If you don’t plan on making any other changes before 1.0, I’d encourage
you to release this now. It’s frustrating to spend the time tracking
down a bug and then find out it’s been fixed previously.

Also, the SVN repository linked from the README at the URL
http://ar-paranoid.rubyforge.org/ returns a 404.

Thanks for the plugin!

-F

Finn S. wrote:

Rick O. wrote:

It’s in SVN along with a few more additions. I’m just waiting for
Rails 1.0 so I can release aap v0.3 and piggy back on the tidal wave
of interest.

If you don’t plan on making any other changes before 1.0, I’d encourage
you to release this now.

Well this was a poorly timed comment seeing as Rails went 1.0 a few
hours after I wrote this.

-F