How to customize Rails 3 STI column name

后端 未结 4 1897
旧巷少年郎
旧巷少年郎 2020-12-31 11:08

I have a class named Post:

class Post < ActiveRecord::Base
end

I have a class named Question that inheriting f

4条回答
  •  旧时难觅i
    2020-12-31 11:29

    You will need to set your column type using self.inheritance_column Then you will have to provide your own behavior for the following method: "sti_class_for(type_name)" which is located in this file "activerecord/lib/active_record/inheritance.rb"

    so you will have to monkey patch the above file.

    This is not the recommended way, you will have to make a migration and change all the values to match your class name.

提交回复
热议问题