Railsにポリモーフィック関連という機能があります。 Polymorphic Associations - Active Record Associations - Ruby on Rails Guides class Picture < ActiveRecord::Base belongs_to :imageable, polymorphic: true end class Employee < ActiveRecord::Base has_many :pictures, as: :imageable end class Product < ActiveRecord::Base has_many :pictures, as: :imageable end ざっくりいうと、複数の親Modelに属するような子Modelの関連を抽象化してまとめる機能です。詳しくはRails Guidesや以
![Rails ポリモーフィック関連の関連名の命名 - 130単位](https://cdn-ak-scissors.b.st-hatena.com/image/square/0b17303f2d32e7c3be4eb26f51ecf15f747f3215/height=288;version=1;width=512/http%3A%2F%2Fecx.images-amazon.com%2Fimages%2FI%2F41khR9aT0iL._SL160_.jpg)