rake db 中的 Ruby on Rails 错误:迁移语法错误,意外的 $end,期望 '}'
当我运行 rake db:migrate 时出现此错误 *db/migrate//004_add_data_to_measurement_type_and_measurement_unit.rb:3:无效的多字节字符 (US-ASCII) db/migrate//004_add_data_to_measurement_type_and_measurement_unit.rb:3:无效的多字节字符 (US-ASCII) db/migrate//004_add_data_to_measurement_type_and_measurement_unit.rb:3:语法错误,意外的 $end,期待“}” ...加速' => [{:name =>'m/s²', :si =>; true, :conversion_f...*
然后我使用 *$ ruby -wc db/migrate/004_add_data_to_measurement_type_and_measurement_unit.rb* 检查它并得到相同的错误。
我确信我拥有所有正确的宝石,因此我通过删除行中的上标进行测试,使其从 :name =>'m/s²' 变为 :name =>'m/s'。这消除了错误。
但问题是我需要上标并且不知道以前的开发人员如何设法在此上运行 db:migrate 。你见过类似的东西吗?
谢谢
I get this error when I run rake db:migrate
*db/migrate//004_add_data_to_measurement_type_and_measurement_unit.rb:3: invalid multibyte char (US-ASCII)
db/migrate//004_add_data_to_measurement_type_and_measurement_unit.rb:3: invalid multibyte char (US-ASCII)
db/migrate//004_add_data_to_measurement_type_and_measurement_unit.rb:3: syntax error, unexpected $end, expecting '}'
...celeration' => [{:name =>'m/s²', :si => true, :conversion_f...*
Then I checked it using *$ ruby -wc db/migrate/004_add_data_to_measurement_type_and_measurement_unit.rb* and got the same error.
I was sure that I have all the right gems in place, so I tested by removing the superscript in the line, making it :name =>'m/s' from :name =>'m/s²'. This removed the error.
But problem is that I need the superscript and do not know how previous developer managed to run the db:migrate on this. Have you seen something similar?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是上标不是 ASCII。
以前的开发人员可能已经设置了一些内容,以便始终假定 UTF-8,但是您应该能够通过在
脚本顶部附近添加魔术注释来专门为此脚本执行此操作。
The problem is that the superscript is not ASCII.
The previous developer may have set something so that UTF-8 was always assumed, but you should be able to do it for this script specifically by adding the magic comment
near the top of the script.