Skip to content

index_name STI inheritance problem #92

@felixbuenemann

Description

@felixbuenemann

The behavior of Class.index_name is not as expected when using concerns and STI:

module Searchable
  extend ActiveSupport::Concern
  included do
    include Elasticsearch::Model
    index_name "app_name-#{Rails.env}-#{table_name}"
  end
end

class Post < ActiveRecord::Base
  include Searchable
end

class Post::News < Post; end

puts Post.index_name
=> "appname-development-posts" [OK]
puts Post::News.index_name
=> "post-news" [Expected: "appname-development-posts"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions