Pat Maddox
2005-Dec-11 06:42 UTC
Problem with acts_as_paranoid: "ArgumentError: Unknown key(s): group"
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 Smith
2005-Dec-13 16:59 UTC
Re: Problem with acts_as_paranoid: "ArgumentError: Unknown key(s): group"
Pat Maddox wrote:> 1) Error: > test_add_message_to_existing_ticket(TicketTest): > ArgumentError: Unknown key(s): group >...> > 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.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
Rick Olson
2005-Dec-13 17:42 UTC
Re: Re: Problem with acts_as_paranoid: "ArgumentError: Unknown key(s): group"
> 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=3711It''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
Finn Smith
2005-Dec-13 21:11 UTC
Re: Problem with acts_as_paranoid: "ArgumentError: Unknown key(s): group"
Rick Olson 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 Smith
2005-Dec-13 21:47 UTC
Re: Problem with acts_as_paranoid: "ArgumentError: Unknown key(s): group"
Finn Smith wrote:> Rick Olson 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
Reasonably Related Threads
- acts_as_paranoid Unknown key(s): with_deleted
- acts_as_paranoid overrides ActiveRecord::Base??
- Getting Acts_as_Paranoid to work with validates_uniqueness_of
- acts_as_paranoid --> undefined method `constrain' for class `Class'
- problems with acts_as_paranoid (noticed while using acts_as_versioned)