ledermann / rails-settings

Manage settings with Ruby on Rails
MIT License
1k stars 137 forks source link

NoMethodError: undefined method `default_settings' for #<Class:0x007f83b8c57ab8> #81

Open adiakritos opened 6 years ago

adiakritos commented 6 years ago

It appears that the target class isn't being assigned a default_settings hash. Why might this be the case?

I've tried it on two different models in our codebase.

Using Rails 3.2.22 and Ruby 2.3.3

olliebennett commented 6 years ago

Does a normal call (such as @record.settings(:some_configured_type)) work? Interested to see whether there's a general problem with the gem loading or whether it's specific to the default_settings hash.

Which gem version are you using?

benpixel commented 6 years ago

I'm having a similar problem using 2.4.3. Here's an example:

shop = Shop.first
settings = RailsSettings::SettingObject.find_by(target_id: shop.id, target_type: "Shop")
# settings returns RailsSettings::SettingObject with all settings thats good
# settings.discount also returns good data
settings.blank? # this gives error, also .present? etc

Error:

NoMethodError: undefined method `default_settings' for #<Class:0x00007f9bc74aac58>
Did you mean?  default_extensions
from /Users/benjam1n/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-5.2.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
olliebennett commented 6 years ago

That's strange...

Are you able to configure a model in the same, minimal way and see if you can reproduce?