huacnlee / rails-settings-cached

Global settings for your Rails application.
Other
1.06k stars 202 forks source link

can't use source method in setting model #179

Closed lethunder closed 4 years ago

lethunder commented 4 years ago

hello eveyone,

this line in setting model

source Rails.root.join("config/app.yml")

generates and error /home/lethunder/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/dynamic_matchers.rb:22:in method_missing': undefined methodsource' for # (NoMethodError)

model looks like this class Setting < RailsSettings::Base source Rails.root.join("config/app.yml")

cache_prefix { "v1" }

end

Any idea?

ruby 2.6.5p114 Rails 5.2.4.1

huacnlee commented 4 years ago

The new version of rails-settings-cached has been remove source method.

Please checkout the README guides to get a right way to use it.

lethunder commented 4 years ago

thanks for your quick answer. i red readme. But does it mean that is no more possible to use app.yml with the gem?

huacnlee commented 4 years ago

NO, it will not supports it.

The new version changed to use field method to define setting keys in app/models/setting.rb.

Here is an example:

https://github.com/ruby-china/homeland/blob/master/app/models/setting.rb

lethunder commented 4 years ago

thanks