Skip to content


Idiomatic Ruby #8

arronmabrey opened this Issue · 1 comment

2 participants


Generally in ruby most developers don't do much explicit type checking. It's not a big deal but I had to crack open the source to see that it required a String. The error message wasn't even clear about that.
A better approach might be to call the method .to_s on the user_id and coerce it into a string inside that method.

The use case is a simple rails example.

u = User.find 53
Analytics.identify(user_id:, traits:{email:,twitter: u.twitter_name, username: u.username})
# => ArgumentError: Must supply a non-empty user_id

The id in that case is a number so it failed.

So it forces me to call the method like this with to_s on the

Analytics.identify(user_id:,   ...)
# => true
@calvinfo calvinfo closed this in 6b06dad
Segment member

Good call, I just updated it to use to_s internally. You're totally right - we shouldn't have missed it in the first place!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.