当我尝试在我的测试生产服务器上加载我的网站的某些页面(实际上是大多数页面)时,我遇到了一条奇怪的错误消息。
Started GET "/students" for 10.0.0.68 at Mon Sep 17 12:53:16 +0100 2012
Processing by StudentsController#index as HTML
Rendered shared/_alerts.html.erb (0.7ms)
Rendered students/_student_search.html.erb (0.0ms)
Rendered students/index.html.erb within layouts/application (17.8ms)
Completed 500 Internal Server Error in 92ms
ActionView::Template::Error (syntax error on line 4, col 586: ` state: ["北海道","青森県","岩手県","宮城県","秋田県","山形県","福島県","茨城県","栃木県","群馬県","埼玉県","千葉県","東京都","神奈川県","新潟県","富山県","石川県","福井県","山梨県","長野県","岐阜県","静岡県","愛知県","三重県","滋賀県","京都府","大阪府","兵庫県","奈良県","和歌山県","鳥取県","島根県","岡山県","広島県","山口県","徳島県","香川県","愛媛県","高知県","福岡県","佐賀県","長崎県","熊本県","大分県","宮崎県","鹿児島県","沖縄県"]'):
59: <% end %>
60:
61: <div class="sidebar_item">
62: <h2>Filter By <%= t(:class) %></h2>
63: <div class="content">
64:
65: <% if Klass.where(:tutor_group => false).count > 0 %>
app/views/students/index.html.erb:62:in `_app_views_students_index_html_erb___542210558__648905548'
app/views/students/index.html.erb:35:in `_app_views_students_index_html_erb___542210558__648905548'
错误消息中出现的任何页面始终相同(相同的行号和列号),但文件名不同,引用的代码也会更改。据我所知或可以看到,我的代码中没有任何这些日文字符。这似乎是一些编码问题,但我真的不知道,我不知道从哪里开始调试它。
我的环境:
deploy@mike-test:~$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
deploy@mike-test:~$ rails -v
Rails 3.2.0
deploy@mike-test:~$ gem -v
1.8.15
deploy@mike-test:~$ /opt/nginx/sbin/nginx -V
nginx version: nginx/1.2.3
built by gcc 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_gzip_static_module --with-cc-opt=-Wno-error --with-pcre=/tmp/root-passenger-16778/pcre-8.31 --add-module=/usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.17/ext/nginx
deploy@mike-test:~$ passenger -v
Phusion Passenger version 3.0.17
Ubuntu是11.04。
更新:好的,我把问题缩小了一些。弄清楚它与方法调用t(:class)有关,这是一个用于翻译的rails辅助方法,并且在我的视图中出现了很多(我是这个应用程序的新手,所以仍然关注它是如何的书面)。根据存在的两个区域设置文件判断,这意味着返回“School”或“Class”,具体取决于区域设置。但我仍然不知道为什么它会导致这个错误。
答案 0 :(得分:0)
似乎你需要处理正确的字符编码。以下是有关将force_encoding
或encoding
用于UTF-8的快速调查结果。
答案 1 :(得分:0)
@Hates_在评论中为我解决了这个,所以我会复制他放在这里的内容,以便我接受它作为答案:
关于这个问题的答案 heroku run db:migrate fail as rake aborted 应该有所帮助:https://stackoverflow.com/a/12451678