Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- 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 17 18 19 20 |
# File 'lib/no_limits.rb', line 10 def self.has limit, name, = {} if limit > 1 if ActiveRecord::VERSION::MAJOR < 4 # support for active_record versions below 3 has_many name.to_sym, { limit: limit }.merge() else has_many name.to_sym, -> { limit(limit) }, # support for active_record version 4 end else has_one name.to_sym, end end |