如何在全局的Rails中设置#encoding:utf-8
现在我在每个控制器中使用# encoding: utf-8
,其中:通知消息不在拉丁语中我试图将它放在ApplicationController中,试图在顶部添加 application.html.erb,没有用,有什么帮助吗?
编辑: config.encoding =“utf-8”也在application.rb中设置
编辑:
此代码出现错误:
redirect_to root_url, :notice => "Вышли успешно"
这是一个错误
:syntax error, unexpected $end, expecting '}' ..._or_to root_url, :notice => 'Вышли успешно.' }
这是ruby 1.9的Set global default encoding的副本,但在你的情况下,我建议使用I18n
:
redirect_to root_url, :notice => I18n.t 'sessions.destroy.success' # config/locales/ru.yml ru: sessions: destroy: success: Вышли успешно
至于locales键命名,AFAIK没有约定,这里我使用“controller_name.action_name.result”方案。
- 在rails 3中模拟用户的消息
- 使用与今天的日期匹配的日期时间查找记录 – Ruby on Rails
- Rails 4如何在视图中使用渲染布局选项?
- Rails路由和控制器参数
- Github API使用OAuth访问私有存储库
- 捆绑安装失败 – 使用github url的Gem – 有什么问题?
- 使用Devise after_sign_in_path_for重定向循环
- GSM编码的WAV文件在浏览器中
- Rails应用程序错误 – ActiveRecord :: PendingMigrationError正在等待迁移; 运行’rake db:migrate RAILS_ENV = development’来解决此问题