开发者

How can I create activerecord models that are subsets of a certain model?

开发者 https://www.devze.com 2022-12-30 01:17 出处:网络
I\'ve seen this before but can开发者_StackOverflow\'t figure out what the correct term is.Basically, I\'d like to create models for a specific subset of table data.E.g. (these are not the real classes

I've seen this before but can开发者_StackOverflow't figure out what the correct term is. Basically, I'd like to create models for a specific subset of table data. E.g. (these are not the real classes)

class Person < ActiveRecord::Base

class Man < Person
  <something here> :gender => 'male'


If you are trying to create a single table inheritance, than I am fairly certain that this is the correct syntax. Just don't forget to define the type field in the table.

class Person < ActiveRecord::Base
end

class Man < Person 
end

Edit: Removed the

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号