module ActiveFixture::Associations::ClassMethods

Public Instance Methods

has_many(model) click to toggle source
# File lib/active_fixture/associations.rb, line 9
def has_many(model)
  class_name = model.to_s.camelize.singularize
  foreign_key = self.name.to_s.underscore + '_id'

  define_method model do
    class_name.constantize.find_by foreign_key, self.id
  end
end