Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has_settings for sub classes doesn't work #68

Open
SanderMander opened this issue Jul 29, 2015 · 3 comments
Open

has_settings for sub classes doesn't work #68

SanderMander opened this issue Jul 29, 2015 · 3 comments

Comments

@SanderMander
Copy link

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
@kitwalker12
Copy link

@SanderMander facing same issue. your monkey patch worked.
will work on a PR to support STI classes. The workaround is detailed here

@zauzaj
Copy link

zauzaj commented Jul 18, 2018

@kitwalker12 @SanderMander facing same issue. Any news about fix ?

@ruvzi
Copy link

ruvzi commented Jul 21, 2018

RailsSettings::SettingObject.class_eval do
  private
  def _target_class
    target.class
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants