class ActiveRecord::Base
Monkey patch ActiveRecord::Base
Public Class Methods
has(limit, name, options = {})
click to toggle source
# File lib/no_limits.rb, line 10 def self.has limit, name, options = {} if limit > 1 if ActiveRecord::VERSION::MAJOR < 4 # support for active_record versions below 3 has_many name.to_sym, { limit: limit }.merge(options) else has_many name.to_sym, -> { limit(limit) }, options # support for active_record version 4 end else has_one name.to_sym, options end end