Ok, it's not a answer about why rails is adding 'basis
' but it will work for you.
Use set_table_name 'contributor_name_bases'
in your model.
Rails: Creating Wrong Table Name With a Namespaced STI
-
11-04-2022 - |
質問
I have a model which uses STI:
class Contributor::Name < Contributor::NameBase
...
end
From this model:
class Contributor::NameBase < ActiveRecord::Base
...
end
Whenever Contributor::Name
gets instantiated, I receive this error:
Mysql2::Error: Table 'shelflives_development.contributor_basis_name_bases' doesn't exist: SHOW FULL FIELDS FROM `contributor_basis_name_bases`
It seems that instead of looking up the table contributor_name_bases
, ActiveRecord is looking up contributor_basis_name_bases
. Why is adding basis
between contributor
and name_bases
? How can I get it to stop?
解決
所属していません StackOverflow