searchlogic icon indicating copy to clipboard operation
searchlogic copied to clipboard

scope_procedure should send arguments if the options is a symbol

Open rainchen opened this issue 15 years ago • 0 comments

class User < ActiveRecord::Base scope_procedure :foo, :bar def self.bar(foo) end end

User.foo("bar") will raise arguments not matching error.

The issue code should be:

  def alias_scope(name, options = nil)
    alias_scopes[name.to_sym] = options
    (class << self; self end).instance_eval do
      define_method name do |*args|
        case options
        when Symbol
          send(options) # should be send(options, *args)
        else
          options.call(*args)
        end
      end
    end
  end

rainchen avatar Mar 20 '10 12:03 rainchen