0

I'm using rails 5 with ruby 2.3.3 . Today I added a gem, there was a version conflict so I took the gem out. Since then dot notation such as hash.test no longer works. It gives NoMethodError: private method test called for {:test=>"value"}:Hash

How can I access hashes with dot notation again?

monty_lennie
  • 2,871
  • 2
  • 29
  • 49

1 Answers1

2

Whatever you're using to use dot-notation to access a hash is probably using method_missing to trap your dot-notation method calls. But everything has a test method because Kernel#test exists and everything includes Kernel; also, pretty much everything in Kernel is private because Kernel is where methods go that we want to pretend are functions. For example:

> 'pancakes'.test
NoMethodError: private method `test' called for "pancakes":String

I suspect that you problem is your choice of :test as hash key.

mu is too short
  • 426,620
  • 70
  • 833
  • 800