Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/no_limits.rb

Overview

Monkey patch ActiveRecord::Base

Class Method Summary collapse

Class Method Details

.has(limit, name, options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/no_limits.rb', line 10

def self.has limit, name, options = {}
if limit > 1
   has_many name.to_sym, -> { limit(limit) }, options
 else
 	has_one name.to_sym, options
 end
end