2012-03-20 46 views
0

現在,我在每個控制器,在使用# encoding: utf-8:通知消息不是拉丁 我試圖把它放在ApplicationController中,試圖添加<meta charset="utf-8">在application.html.erb的頂部,沒有任何幫助?如何設置#encoding:UTF-8在Rails的全球

編輯: config.encoding = 「UTF-8」 application.rb中還設置

編輯:

redirect_to root_url, :notice => "Вышли успешно" 
:與此代碼出現

錯誤

這裏是錯誤

:syntax error, unexpected $end, expecting '}' ..._or_to root_url, :notice => 'Вышли успешно.' } 
+0

據我所知,Rails自動使用UTF-8。你確切的問題是什麼? UTF-8部分如何展示?此代碼出現 – Vapire 2012-03-20 16:14:55

+0

錯誤: – 2012-03-20 16:18:10

+0

[向所有文件添加「#編碼:utf-8」可能出現重複](http://stackoverflow.com/questions/7037094/add-coding-utf-8-to-all-文件) – fl00r 2012-03-20 16:20:03

回答

2

這是Set global default encoding for ruby 1.9重複,但在你的情況我建議使用I18n

redirect_to root_url, :notice => I18n.t 'sessions.destroy.success' 

# config/locales/ru.yml 
ru: 
    sessions: 
    destroy: 
     success: Вышли успешно 

至於語言環境鍵的命名,據我所知有沒有約定,這裏我用「controller_name.action_name.result」方案。