Skip to content

Inheritance seems broken #2573

@sineway

Description

@sineway

Steps to reproduce

I try to make general purpose site section, that may have any content:

# app/components/ui/base/section/view.rb
module Ui
  class Base::Section::View < ViewComponent::Base
    def initialize
      super()
      # internal stuff
    end
  end
end
/ app/components/ui/base/section/view.slim
.section
  .section__content
    = content

When I use it as is, it works as expected:

= render Ui::Base::Section::View.new do
  h1 Hello World

The strange thing happens, when I try to create another component, base on it:

# app/components/ui/base/hero/view.rb
module Ui
  class Base::Hero::View < Base::Section::View
    def initialize
      super()
      # internal stuff
    end
  end
end

I add its own template, e.g. hero/view.slim, and try to render it:

= render Ui::Base::Hero::View.new do
  h1 Hello World

The following error occurs:

undefined method 'upcase' for nil

Expected behavior

Rendered contents of the hero/view.slim template.

System configuration

Rails version:
8.1.2

Ruby version:
4.0.1

Gem version:
4.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions