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

active_type 1.4.0 introduced a bug when extending a record in level 2 #142

Closed
FLeinzi opened this issue May 12, 2021 · 0 comments
Closed

Comments

@FLeinzi
Copy link
Contributor

FLeinzi commented May 12, 2021

Hi,

this commit in 1.4.0 introduced a bug when extending an already extended record again

Given we have these models:

class Note < ActiveRecord
end

class Note
  class Form < ActiveType::Record[Note]
    attribute :some_attribute
  end
end

class Note
  class SuperSpecialForm < ActiveType::Record[Form]
    attribute :some_special_attribute
  end
end

Then my tests for Note::SuperSpecialForm will break, because Rails cannot resolve the model_name properly

$ Note.model_name.singular_route_key
=> "note"

$ Note::Form.model_name.singular_route_key
=> "note" # level 1 is correct

$ Note::SuperSpecialForm.model_name.singular_route_key
=> "note_form" # this is not correct

I already figured out, that it comes from the deeper hierarchy (extension of a extension of a record) and this piece of code from the commit above:

dup_model_name = ActiveModel::Name.new(self, namespace, extended_record_base_class.name)

but I couldn't solve the problem.

Maybe we have to climb via extended_record_base_class until we reach a "normal" record (no ActiveType::Record!)

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

1 participant