Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol#to_proc is breaking my migrations #43

Closed
asterite opened this issue Mar 23, 2011 · 1 comment
Closed

Symbol#to_proc is breaking my migrations #43

asterite opened this issue Mar 23, 2011 · 1 comment

Comments

@asterite
Copy link

Hi,

Your Symbol#to_proc implementation is this:

def to_proc; proc { |obj, *args| p obj; p self; p args; obj.send(self, *args) }; end

However, this breaks one of my migrations.

add_index :address_sources, [:application_id, :address], :unique => true

This basically triggers the method_missing method in Migration, that starts like this:

def method_missing(method, *arguments, &block)
    arg_list = arguments.map(&:inspect) * ', '
    ...
end

arguments in this case is:

[:address_sources, [:application_id, :address], {:unique => true}]

Since your proc has |obj, *args|, for the second argument, which is an array, it seems obj gets to be :application_id and *args gets to be [:address], and thus the inspect method is being called with :address and this explodes.

I checked ActiveSupport's implementation of this, working fine, and it's:

Proc.new { |*args| args.shift.__send__(self, *args) }

Can you change it to that?

Thanks!

@sprsquish
Copy link
Contributor

use a better version of to_proc. closed by 1b3b9ce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants