Rails associations has_many through ban/archive solution?
问题 I'm new in Rails and am working on a problem. I have two tables: Shoes and Socks A Shoe can have many Socks, but only one active Sock. Other Socks are inactive. All Socks are also unique with unique patterns. I want to make sure I don't have socks with the same pattern. I think I can do this three ways 1) Using an additional column in table socks to represent the active sock class Shoe < ActiveRecord::Base has_many :socks end class Sock < ActiveRecord::Base belongs_to :shoe end class