Sha256: 1739b671664a9f47b08eb8e9175e80a89f6014d401ac3a710941e6005b1ca588
Contents?: true
Size: 975 Bytes
Versions: 19
Compression:
Stored size: 975 Bytes
Contents
# Add support for :scope => :my_scope to associations module ActiveRecord module Associations module ThroughAssociationScope # No such module in ActiveRecord any more - there is only ThroughAssociation def construct_scope_with_scope s = construct_scope_without_scope s[:find][:scope] = @reflection.options[:scope] s end alias_method_chain :construct_scope, :scope end end if false # DISABLED Getting Rails 3.1 working module SpawnMethods def apply_finder_options_with_scope(options) scopes = [] Array.wrap(options.delete(:scope)).each do |s| if s.is_a?(Hash) s.each_pair{|k,v| scopes << [k,v] } else scopes << [s] end end relation = apply_finder_options_without_scope(options) return relation if scopes.empty? scopes.inject(relation) {|r, s| r.send *s } end alias_method_chain :apply_finder_options, :scope end end
Version data entries
19 entries across 19 versions & 1 rubygems