moduleActiveRecordclassBasedefself.has_many(name)puts"#{self} has many #{name}"#定義 Dynamic methoddefine_method(name)doputs"Select * From #{name} Where.."puts"Return #{name}"[]endendendendclassMovie<ActiveRecord::Base#self.has_many(:reviews)has_many:reviewshas_many:genresendclassProject<ActiveRecord::Basehas_many:tasksendmovie=Movie.newmovie.reviewsproject=Project.newproject.tasks#=>Movie has many reviews#=>Movie has many genres#=>Project has many tasks#=>Select * From reviews Where..#=>Return reviews#=>Select * From tasks Where..#=>Return tasks