Errors for STI models (undefined method for paths)
Created by: dmitryzuev
I have models:
- Topic < ActiveRecord::Base
- Topics::News < Topic
- Topics::Article < Topic
The $ rails generate administrate:install
created following routes:
# config/routes.rb
# ...
namespace :admin
resources :topics
root to: 'topics#index'
end
And /admin/ had given me following error:
undefined method `admin_topics_article_path' for #<#<Class:0x007fb0bbf85e30>:0x007fb0c7d159f0>
Did you mean? admin_topics_path
I think it's problem with how Administrate or Rails handles single table inheritance and model_name
of STI models.
My temporary workaround:
class Topic < ActiveRecord::Base
def self.model_name
return super if self == Topic
Topic.model_name
end
end