Any idea why I am getting this error:
Exception encountered: #<NoMethodError: undefined method `assert_valid_keys' for :widget:Symbol>
when I try to do a Factory.build(:widget)
on the following model:
class Widget < ActiveRecord::Base belongs_to :designer, :vendor # ... end
When I remove the belongs_to
line the error goes away.
A method or statement also returns undefined if the variable that is being evaluated does not have an assigned value. A function returns undefined if a value was not returned .
This is a common Ruby error which indicates that the method or attribute for an object you are trying to call on an object has not been defined.
belongs_to :designer, :vendor
won't work. :vendor
is treated like an option. And, of course, there isn't such an option. See docs for further information.
If you need two belongs_to
relations, just change your code to:
belongs_to :designer belongs_to :vendor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With