问题描述
现在,我正在每个控制器中使用,其中:通知消息不在拉丁文
我试图将它放在ApplicationController中,试图在application.html.erb的顶部添加< meta charset =utf-8>
,没有工作任何帮助?
编辑:
config.encoding =utf-8也设置在 application.rb
编辑:
/ p>
redirect_to root_url,:notice => Вышлиуспешно
这里有一个错误
:语法错误,意外的$ end,expecting'}'..._或_to root_url,:notice => 'b $усусусусусусусусусусус}}}}}}} of of of of>>>>>>>>>>>>>>>>>> of>>>>>>>>>>>>>>>>>>>>>> ,但在您的情况下我建议使用 I18n
: redirect_to root_url,:notice => ; I18n.t'sessions.destroy.success'
#config / locales / ru.yml
ru:
会话:
destroy:
成功:对于本地密钥命名,AFAIK没有约定,这里我使用controller_name.action_name。结果方案。
now i'm using # encoding: utf-8
in every controller, where :notice message is not in latin
i've tried to put it in ApplicationController, tried to add <meta charset="utf-8">
at the top of application.html.erb, none worked, any help ?
EDIT:
config.encoding = "utf-8" also set in application.rb
EDIT:
error appears with this code:
redirect_to root_url, :notice => "Вышли успешно"
and here's an error
:syntax error, unexpected $end, expecting '}' ..._or_to root_url, :notice => 'Вышли успешно.' }
解决方案 This is a duplicate of Set global default encoding for ruby 1.9, but in your case I suggest using the I18n
:
redirect_to root_url, :notice => I18n.t 'sessions.destroy.success'
# config/locales/ru.yml
ru:
sessions:
destroy:
success: Вышли успешно
As for locales key naming, AFAIK there's no convention, here I use "controller_name.action_name.result" scheme.
这篇关于如何在全局Rails中设置#encoding:utf-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!