ruby 魔法编码不起作用

发布于 01-07 08:07 字数 899 浏览 2 评论 0原文

我有一个 Rails 应用程序,并且不断收到此错误

  /srv/projects/app/controllers/application_controller.rb:174: invalid multibyte char (US-ASCII) /srv/projects/app/controllers/application_controller.rb:174: invalid multibyte char (US-ASCII) /srv/projects/app/controllers/application_controller.rb:174: syntax error, unexpected $end, expecting ')' ...e_title = h("#{project_name} — #{name || translate_locatio... ... ^

,修复方法应该是 这里但是当我在应用程序控制器顶部添加该行时我仍然收到错误...我什至重新启动了apache

这是我的应用程序控制器

# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

# encoding: utf-8


class ApplicationController < ActionController::Base
# encoding: utf-8

I have a rails application and i keep getting this error

  /srv/projects/app/controllers/application_controller.rb:174: invalid multibyte char (US-ASCII) /srv/projects/app/controllers/application_controller.rb:174: invalid multibyte char (US-ASCII) /srv/projects/app/controllers/application_controller.rb:174: syntax error, unexpected $end, expecting ')' ...e_title = h("#{project_name} — #{name || translate_locatio... ... ^

and the fix should be here but when i added the line on top of my application controller i still get the error...i even restarted apache

Here is my application controller

# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

# encoding: utf-8


class ApplicationController < ActionController::Base
# encoding: utf-8

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

椒妓2025-01-14 08:07:49

编码注释必须先于文件顶部 - 包括其他注释(如果有的话,shebang 除外)。

The encoding comment must be on top of the file before anything else - including other comments (except the shebang if you have one).

变身佩奇2025-01-14 08:07:49

你的类应该是这样的:(

# encoding: utf-8
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base

魔术评论在顶部)

Your class should look like this:

# encoding: utf-8
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base

(with the magic comment at the top)

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