rails-settings
rails-settings copied to clipboard
has_settings for sub classes doesn't work
in case when A < ActiveRecord::Base and B < A has_settings doesn't work correct inside B. Probably this is caused because target_type use base_class which will return A even if called inside B. so _target_class will return wrong class and settings always will be nil.
I think overriding of target_type should solve problem, but I have not tested it well yet.
def target_type
target.class.to_s
end
@SanderMander facing same issue. your monkey patch worked. will work on a PR to support STI classes. The workaround is detailed here
@kitwalker12 @SanderMander facing same issue. Any news about fix ?
RailsSettings::SettingObject.class_eval do
private
def _target_class
target.class
end
end