I am getting the following error [ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8)]
我得到以下错误[ActionView: Template: error(不兼容字符编码:ASCII-8BIT和UTF-8)]
Here is the log...
这是日志……
Completed 500 Internal Server Error in 318ms
Jan 09 23:29:19 burro app/web.1: ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8):
Jan 09 23:29:19 burro app/web.1: 97: <!-- <td><%= row.notes.gsub("\n", "<br>").html_safe %></td> -->
Jan 09 23:29:19 burro app/web.1: 98: </tr>
Jan 09 23:29:19 burro app/web.1: 99: <% end %>
Jan 09 23:29:19 burro app/web.1: 100: </tbody>
Jan 09 23:29:19 burro app/web.1: 101: </table>
Jan 09 23:29:19 burro app/web.1: 102:
HERE IS THE CODE:
这是代码:
<td><%= row.notes.force_encoding("utf-8") %></td>
<!-- <td><%= row.notes.gsub("\n", "<br>").html_safe %></td> -->
</tr>
<% end %>
I have all these in the correct rb and erb files?
我有正确的rb和erb文件吗?
<%# encoding: utf-8 %>
config.encoding = "utf-8"
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
@data.each do |sr|
sr.notes = sr.notes.to_s.force_encoding("UTF-8")
end
The data in the db is encrypted so I can't run a query on my MongoDB data to see what special character is causing the issue, when displaying records?
db中的数据是加密的,所以在显示记录时,我不能对我的MongoDB数据运行查询来查看导致问题的特殊字符?
1 个解决方案
#1
0
You can try below
你可以尝试以下
config/application.rb
should consist
配置/应用程序。rb应该包含
config.encoding = "utf8"
Also in your environments file
也在您的环境文件中
in config/environments/development.rb
or config/environments/production.rb
should have
在config /环境/发展。rb或配置/环境/生产。rb应该
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
and
和
Also use the below in .rb file
也可以使用下面的.rb文件。
# encoding: utf-8
It tells ruby to interpret the source of the file as utf-8, even if it doesn't contain any non-ascii characters
它告诉ruby将文件的源代码解释为utf-8,即使它不包含任何非ascii字符
in that particular file
在那个特定的文件
hope it will solve this problem
希望它能解决这个问题。
#1
0
You can try below
你可以尝试以下
config/application.rb
should consist
配置/应用程序。rb应该包含
config.encoding = "utf8"
Also in your environments file
也在您的环境文件中
in config/environments/development.rb
or config/environments/production.rb
should have
在config /环境/发展。rb或配置/环境/生产。rb应该
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
and
和
Also use the below in .rb file
也可以使用下面的.rb文件。
# encoding: utf-8
It tells ruby to interpret the source of the file as utf-8, even if it doesn't contain any non-ascii characters
它告诉ruby将文件的源代码解释为utf-8,即使它不包含任何非ascii字符
in that particular file
在那个特定的文件
hope it will solve this problem
希望它能解决这个问题。