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

[Fix] Nested module include is not supported until ruby 3.0 #13

Merged
merged 2 commits into from
Aug 11, 2022

Conversation

khiav223577
Copy link
Owner

@khiav223577 khiav223577 commented Aug 11, 2022

It will raise undefined method `remove_alias_attribute' in ruby 2.x

Ruby 2.6, 2.7

module ModuleA
  def a
    p 'a'
  end
end

module ModuleB
  def b
    p 'b'
  end
end

class C
  def c
    p 'c'
  end
end

C.include ModuleA
ModuleA.include ModuleB

C.new.a
# => "a"

C.new.b
# NoMethodError (undefined method `b' for #<C:0x00007fc0e1095b88>)

C.new.c
# => "c"

Ruby 3.0

module ModuleA
  def a
    p 'a'
  end
end

module ModuleB
  def b
    p 'b'
  end
end

class C
  def c
    p 'c'
  end
end

C.include ModuleA
ModuleA.include ModuleB

C.new.a
# => "a"

C.new.b
# => "b"

C.new.c
# => "c"

@khiav223577 khiav223577 merged commit 3ca1458 into master Aug 11, 2022
@khiav223577 khiav223577 deleted the fix/ruby branch August 11, 2022 11:30
require 'minitest/autorun'

require 'lib/mysql2_connection'

require 'acts-as-taggable-on'

require 'adaptive_alias'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this line to below require 'lib/mysql2_connection' in order to let ActiveModel::AttributeMethods be included first and then include adaptive_alias patch, which will cause problem in ruby 2.6, 2.7.

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

Successfully merging this pull request may close these issues.

None yet

1 participant