Sunday, April 22, 2012

Re: [Rails] trying to work out what is going on with monkey patch of String

On 20 April 2012 20:40, Jedrin <jrubiando@gmail.com> wrote:
>
>
> Somewhere in all of the ruby code that gets included into this app I
> am working on, there is something that defined String so that the
> following is a valid statement
>
> puts "contact us at " + "info@abc.com"[] + " and say hello"
>
>
>  The app that runs, is able to include that stuff and Ruby doesn't
> complain. When I try to write a test module and
> include some of the code, ruby complains beuse my load paths or some
> part of the configuration is different. I am not really sure.
>
>  If I monkey patch string like below, it seems to stop the errors, but
> I am not sure if it could be causing other problems.
>
> class String
>  def [](x=nil,b=nil)
>    self
>  end
> end
>
> I am on windows, but I am using cygwin. I did something like what's
> below, but did not find where [] might be defined:
>
>  find . -name "*.rb" -exec grep -A 15 "class String" {} \; -print > /
> cygdrive/c/tmp/str-patch.txt
>
>
> Any other ideas to figure this out ? How can I tell inside irb or
> something what the code is for "info@abc.com"[]
> or where it is defined ?

You could use ruby-debug (assuming that is available on Windows, I
don't know) and step into "string"[] to see where it is defined.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate