Forum: Ruby on Rails Problem with acts_as_paranoid: "ArgumentError: Unknown key(s

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.
Pat M. (Guest)
on 2005-12-11 08:43
(Received via mailing list)
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:in
`validate_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:in
`find'
    /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:in
`load_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:in
`test_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
Finn S. (Guest)
on 2005-12-13 19:05
(Received via mailing list)
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...


-F
Rick O. (Guest)
on 2005-12-13 19:45
(Received via mailing list)
> and here is the edited version:
> Someone already submitted a patch to fix this problem here:
>
> http://rubyforge.org/tracker/index.php?func=detail...

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...

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

--
rick
http://techno-weenie.net
Finn S. (Guest)
on 2005-12-13 23:16
(Received via mailing list)
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...
>
> 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. (Guest)
on 2005-12-13 23:52
(Received via mailing list)
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
This topic is locked and can not be replied to.