solutions to the annoying “warning: already initialized constant” message

前端 未结 3 1815
抹茶落季
抹茶落季 2021-01-30 08:23

Today I\'ve stumbled upon a tricky issue with Ruby constants. In our team someone created a module, which is included into multiple models. In our (spec) test output this result

3条回答
  •  故里飘歌
    2021-01-30 09:03

    RESET is not a constant if it keeps changing in your code. If you rename it to lower case 'reset', the problem disappears. Ruby thinks Upper case variables are constants and thus displays an error to warn you that a constant has changed.

提交回复
热议问题