Inside template code `true` doesn't respond_to `to_str` #106

Closed
cmwright opened this Issue Feb 19, 2013 · 1 comment

Comments

Projects
None yet
2 participants

Hi All,

Inside an external gem to our company (google-api-client) a true value is passed down to the addressable template code where we get an error

TypeError: Can't convert TrueClass into String or Array.
    from /Users/codywright/.rvm/gems/ruby-1.9.2-p180@vidyard_dashboard/gems/addressable-2.2.8/lib/addressable/template.rb:545:in `block in transform_mapping'
    from /Users/codywright/.rvm/gems/ruby-1.9.2-p180@vidyard_dashboard/gems/addressable-2.2.8/lib/addressable/template.rb:540:in `each'
    from /Users/codywright/.rvm/gems/ruby-1.9.2-p180@vidyard_dashboard/gems/addressable-2.2.8/lib/addressable/template.rb:540:in `inject'
    from /Users/codywright/.rvm/gems/ruby-1.9.2-p180@vidyard_dashboard/gems/addressable-2.2.8/lib/addressable/template.rb:540:in `transform_mapping'
    from /Users/codywright/.rvm/gems/ruby-1.9.2-p180@vidyard_dashboard/gems/addressable-2.2.8/lib/addressable/template.rb:456:in `expand'

I can fix this by aliasing the to_str method to the to_s method like:

class TrueClass
  alias_method :to_str, :to_s
end

Is there some addressable config that should be happening that isn't, or is the bug in what is being passed?

@sporkmonger sporkmonger added a commit that referenced this issue Feb 19, 2013

@sporkmonger sporkmonger Fixes issue #106 with common primitives not being converted to a Stri…
…ng during template expansion.
ac9d34f

@sporkmonger sporkmonger added a commit that referenced this issue Feb 19, 2013

@sporkmonger sporkmonger Fixes issue #106 with common primitives not being converted to a Stri…
…ng during template expansion.
a2ddfa9

@sporkmonger sporkmonger added a commit that referenced this issue Feb 19, 2013

@sporkmonger sporkmonger Fixes issue #106 with common primitives not being converted to a Stri…
…ng during template expansion.
4035cce
Owner

sporkmonger commented Feb 19, 2013

Please update to the latest version of addressable and google-api-client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment