active_record-acts_as:模拟ActiveRecord模型的多表继承

时间:2021-02-06 00:22:22
【文件属性】:
文件名称:active_record-acts_as:模拟ActiveRecord模型的多表继承
文件大小:25KB
文件格式:ZIP
更新时间:2021-02-06 00:22:22
rails activerecord inheritance RailsRuby ActiveRecord :: ActsAs 这是的重构 为ActiveRecord模型模拟多表继承(MTI)。 默认情况下,ActiveRecord仅支持单表继承(STI)。 MTI为您提供了STI的好处,但不必在单个表中放置数十个空字段。 以传统的电子商务应用程序为例:产品具有共同的属性( name , price , image ...),而每种产品都有其自身的属性:例如, pen具有color , book具有author和publisher ,以此类推。 使用多表继承,您可以拥有一个带有公共列的products表,以及一个针对每种产品类型的单独表,即带有color列的pens表。
【文件预览】:
active_record-acts_as-master
----.travis.yml(201B)
----bin()
--------console(185B)
----Guardfile(344B)
----Rakefile(124B)
----gemfiles()
--------rails_6.0.gemfile(148B)
--------rails_master.gemfile(153B)
--------rails_6.1.gemfile(148B)
----_config.yml(27B)
----active_record-acts_as.gemspec(1KB)
----Appraisals(174B)
----Gemfile(139B)
----.rspec(59B)
----spec()
--------rspec_matchers_spec.rb(358B)
--------find_or_initialize_by_spec.rb(667B)
--------active_record_spec.rb(533B)
--------database_helper.rb(603B)
--------actable_spec.rb(2KB)
--------migrations_spec.rb(2KB)
--------acts_as_spec.rb(19KB)
--------spec_helper.rb(354B)
--------models.rb(3KB)
----.gitignore(236B)
----CHANGELOG.md(7KB)
----lib()
--------active_record()
----README.md(6KB)
----LICENSE.txt(1KB)

网友评论