Forum: Ruby on Rails undefined method assert_valid_keys

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.
F8fd54072606eaf5603484e756672034?d=identicon&s=25 John Wells (Guest)
on 2006-01-23 18:52
Guys,

I'm having trouble understanding why I am getting the following error
message. I've double checked my code and everything looks good. Can
anyone share any insight into the message?

Thanks!

John

------------------------------------------------------------------------------
undefined method `assert_valid_keys' for :hangars:Symbol (NoMethodError)
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:343:in
`has_many_without_reflection'
(eval):5:in `has_many'
script/../config/../app/models/site.rb:3
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in
`load'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:in
`require_or_load'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:22:in
`depend_on'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in
`require_dependency'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in
`require_dependency'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:194:in
`const_missing'
./script/../config/../app/controllers/status_controller.rb:18:in
`choose_site'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in
`perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in
`perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
`process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
`process'
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
`dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
`handle_dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in
`service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:172:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:161:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:161:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
`dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
./script/server:3
9473e2460c11fa8da15a21c418825fb9?d=identicon&s=25 eneko (Guest)
on 2006-10-14 19:56
Hi John,

I also have the same issue with rails, did you fix it? if so please send
me something because i'm getting mad

thanks!!
Bfccdb1c41c334fec20e5ede3a7ccfcc?d=identicon&s=25 Guest (Guest)
on 2006-10-18 00:36
Longshot, but I had this problem when I tried to put multiple relations
on the same line, like

class Appln < ActiveRecord::Base
  belongs_to :viewer, :form
end

I had to change it to

class Appln < ActiveRecord::Base
  belongs_to :viewer
  belongs_to :form
end

-Andrew

John Wells wrote:
> Guys,
>
> I'm having trouble understanding why I am getting the following error
> message. I've double checked my code and everything looks good. Can
> anyone share any insight into the message?
>
> Thanks!
>
> John
>
> ------------------------------------------------------------------------------
> undefined method `assert_valid_keys' for :hangars:Symbol (NoMethodError)
566ed16a947eeb12e5f344078a4296f2?d=identicon&s=25 Elliott Pogue (Guest)
on 2007-02-11 18:17
That worked, for whatever reason. Thanks!

Guest wrote:
> Longshot, but I had this problem when I tried to put multiple relations
> on the same line, like
>
> class Appln < ActiveRecord::Base
>   belongs_to :viewer, :form
> end
>
> I had to change it to
>
> class Appln < ActiveRecord::Base
>   belongs_to :viewer
>   belongs_to :form
> end
>
> -Andrew
2bd7446a46f3e5eede1527cc9599e5af?d=identicon&s=25 David Beckwith (dbit)
on 2008-02-25 13:37
undefined method `assert_valid_keys'

occurred for me when I made a method called 'sum' for my /app/duckage.rb
just-for-fun model called Duckage.    In general, it seems like you
should avoid using built-in ruby method names.  (For example, "sum" is
built into some Ruby classes like Array.  Also avoid using built-in
method names for the names of your table columns.  The reason is cuz
Rails relies on method missing, which looks up all the methods in the
inheiritance hierarchy all the way down to Ruby's Object and Kernel
classes and if it doesn't find anything it creates an attr_accessor
method on the fly.  I really should test this hypothesis before posting
it, but I'm pretty sure Rails works like this.

David :)



Elliott Pogue wrote:
> That worked, for whatever reason. Thanks!
>
> Guest wrote:
>> Longshot, but I had this problem when I tried to put multiple relations
>> on the same line, like
>>
>> class Appln < ActiveRecord::Base
>>   belongs_to :viewer, :form
>> end
>>
>> I had to change it to
>>
>> class Appln < ActiveRecord::Base
>>   belongs_to :viewer
>>   belongs_to :form
>> end
>>
>> -Andrew
5d555c04f1b80fbe575c122979fd25e3?d=identicon&s=25 Teja Kantamneni (tejakantamneni)
on 2008-07-21 00:44
Thanks, worked like a magic.
97bd2f0974055dacf53a0643b013b32e?d=identicon&s=25 Petan Cert (petan)
on 2008-11-10 13:35
Thank you so much Andrew !!!



> Longshot, but I had this problem when I tried to put multiple relations
> on the same line, like
>
> class Appln < ActiveRecord::Base
>   belongs_to :viewer, :form
> end
>
> I had to change it to
>
> class Appln < ActiveRecord::Base
>   belongs_to :viewer
>   belongs_to :form
> end
>
> -Andrew
This topic is locked and can not be replied to.