Rails strange error => IndexError: string not matched

前端 未结 2 1683
面向向阳花
面向向阳花 2021-01-07 17:33

I\'ve got a very strange message error. I think it\'s not coming from Ruby but from the unix system.

So, I have the following test file:

require File         


        
相关标签:
2条回答
  • 2021-01-07 17:59

    This happens, for example, when you try to access a string variable as a Hash by mistake.

    s = "a string"
    s["position"] = "an other string"
    
    IndexError: string not matched
        from (irb):5:in `[]='
        from (irb):5
    

    Additional Information

    0 讨论(0)
  • 2021-01-07 18:08

    As Simone points out the error is caused when you think you have a hash but really it a string. Its a genuine Ruby exception. I've had the exception due to a typo in my code. In your case I'm not sure of the cause but it could be something to do with a combination of Ruby / Rails versions.

    You could try up/down grading Ruby or Rails to see if that fixes it.

    For multiple Ruby versions I would highly recommended "RVM":http://rvm.beginrescueend.com/

    0 讨论(0)
提交回复
热议问题