Issue with ActiveModel's partial path when using delegated types in a namespaced model


I can’t seem to get the right partial path from a model inside a module, when using delegated types. (ActiveRecord::DelegatedType)

Here’s what I’m working with:
(“apps” in this context are “features” a user assigns to an account, similar to “Tools” in Basecamp.)

# app/models/app.rb
class App < ApplicationRecord
  delegated_type :app_configurable, types: %w[Apps::TodoList]

# app/models/apps/todo_list.rb
class Apps::TodoList < ApplicationRecord
  has_one :app, as: :app_configurable, touch: true, dependent: :destroy
  has_many :todos, dependent: :destroy

# app/controllers/app_controller.rb
class AppsController < ApplicationController
  def index
    @apps = App.all

# app/views/apps/index.html.erb
<%= render @apps %>

# app/views/apps/_app.html.erb
<%= render app.app_configurable_name, app: app %>

My problem is in the last line, specifically with the return value of the delegated_type name: app.app_configurable_name # => "apps_todo_list"

I want the partial to render from app/views/apps/_todo_list.html.erb

Rails errors with:

ActionView::Template::Error (Missing partial apps/_apps_todo_list, application/_apps_todo_list with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}.

Searched in:
  * "/Users/cabgfx/Sites/tap_app/app/views"
  * "/Users/cabgfx/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actiontext-7.0.1/app/views"

I realise my use case here may not be able to fully rely on automagically getting the right partial path from ActiveModel::Conversion's built-in stuff, but:

Even if I explicitly define to_partial_path on my model, the app.app_configurable_name still resolves to "apps_todo_list".

Is there a bug somewhere, or am I just doing this wrong?

To be clear, everything else works as intended: models save correctly; delegated type and all, routes + URL helpers are computed correctly, etc.

TIA for any pointers!

FWIW, the solution was to pass the delegated type object to render, not simply the string from <delegated_type>_name :bulb:

Like so:

# app/views/apps/_app.html.erb
<%= render app.app_configurable %>