rake db 中的 Ruby on Rails 错误:迁移语法错误,意外的 $end,期望 '}'

发布于 2024-10-07 13:48:31 字数 666 浏览 0 评论 0原文

当我运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟雨扶苏 2024-10-14 13:48:31

问题是上标不是 ASCII。

以前的开发人员可能已经设置了一些内容,以便始终假定 UTF-8,但是您应该能够通过在

# coding: 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

# coding: utf-8

near the top of the script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文