Ruby on rails 为什么我在获取ActionView::Template::错误(不兼容的字符编码:ASCII-8BIT和UTF-8)

Ruby on rails 为什么我在获取ActionView::Template::错误(不兼容的字符编码:ASCII-8BIT和UTF-8),ruby-on-rails,ruby,Ruby On Rails,Ruby,我得到以下错误 ActionView::Template::Error (incompatible character encodings: ASCII-8BIT <td><%= simple_format(row.notes) %></td> ActionView::Template::Error(不兼容的字符编码:ASCII-8BIT) 这是我的ERB文件。客户可以在备注中键入任何内容(ö、`、',等等) 如果我删除这一行,则表示不兼容的错误是 如

我得到以下错误

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT 
<td><%= simple_format(row.notes) %></td> 
ActionView::Template::Error(不兼容的字符编码:ASCII-8BIT)
这是我的ERB文件。客户可以在备注中键入任何内容(ö、`、',等等)

如果我删除这一行
,则表示不兼容的错误是

如果我随后删除
行,则表示错误出现在以下行中(结束tr)

95:
96:        
--


$(文档).ready(函数(){
$(“#日期选择器”).datepicker();
$(“#日期选择器”)。日期选择器(“选项”、“日期格式”、“yy-mm-dd”);
});
函数editEvent(id){
$('eventdetailmodel').model('show');
var请求=$.ajax({
url:“/ems/scheduled\u call\u details”,
键入:“获取”,
数据:{id:id},
数据类型:“json”
});
请求完成(功能(数据){
$('eventId').val(数据id);
$('拾取地址').val(数据.拾取地址);
$('dropoff_address').val(data.dropoff_address);
$('#phone').val(data.notify#phone);
$('#email').val(data.notify#email);
$('#notes').val(data.notes);
$('#datepicker').val(data.edit_date);
$('send#u hour').val(data.edit_hours);
$('send_minutes').val(data.edit_minutes);
$('input[name=ampm][value=“”+data.edit_ampm+'“]”).prop('checked',true);
$('input[name=type][value=“”+data.amb_type+'''“]').prop('checked',true);
});
请求失败(函数(jqXHR,textStatus){
log(“请求失败:+textStatus”);
警报(“请求失败。请关闭对话框窗口并重试。”)
});
}
&时代;
编辑失败!
&时代;
成功!
*
请求者
日期
改善
下降
电话
电子邮件
笔记


“ems”,:action=>“delete_scheduled_call”,:id=>row.id.to_s),数据:{确认:“是否确实要删除此预定呼叫?”}%>
×
编辑事件详细信息
:ems,:action=>:edit_scheduled_call},{:method=>“post”})do%>
收件地址
下车地址
车辆类型


电话 电子邮件 注释 日期 时间 01 02 03 04 05 06 07 08 09 10 11 12 : 00 05 10 15 20 25 30 35 40 45 50 55 上午和下午 提交
我已经有了所有这些(见下文),文件是18个月前在Sublime中创建的,并且没有更改。18个月来一切正常。一位客户在notes页面中键入了一些内容,然后发生了此错误。DB已加密,因此我看不到谁键入了什么以及键入了什么

确保config.encoding=“utf-8”位于application.rb文件中。 确保您正在使用“mysql2”gem。 将#编码:utf-8放在包含utf-8字符的文件顶部。 在environment.rb文件中的::Application.initialize!行上方,添加以下两行:

Encoding.default_external=编码::UTF_8
Encoding.default_internal=Encoding::UTF_8

您使用的ruby和rails版本可能存在重复?否。不重复。此页面已保持18个月不变。一位客户在NOTES字段中键入了一些内容,这使事情变得一团糟。DB已加密,因此我看不到哪个客户键入了什么。使用rails 4.2.4和Rubb更新y 1.9.3Ruby 1.9.3…我很确定这是一个表情符号
95:          
96:       </tr> 
<% # encoding: utf-8 %>
<% content_for :head do -%>
  <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
  <link rel="stylesheet" href="/jquery-ui-1.10.3.custom.min.css" />
  <script>
    $(document).ready(function() {
      $("#datepicker").datepicker();
      $("#datepicker").datepicker("option", "dateFormat", "yy-mm-dd");
    });

    function editEvent(id){
      $('#eventDetailModal').modal('show');
      var request = $.ajax({
        url: "/ems/scheduled_call_details",
        type: "GET",
        data: {id : id},
        dataType: "json"
      });

      request.done(function(data) {
        $('#eventId').val(data._id);
        $('#pickup_address').val(data.pickup_address);
        $('#dropoff_address').val(data.dropoff_address);
        $('#phone').val(data.notify_phone);
        $('#email').val(data.notify_email);
        $('#notes').val(data.notes);
        $('#datepicker').val(data.edit_date);
        $('#send_hour').val(data.edit_hours);
        $('#send_minute').val(data.edit_minutes);
        $('input[name=ampm][value="' + data.edit_ampm + '"]').prop('checked', true);
        $('input[name=type][value="' + data.amb_type + '"]').prop('checked', true);
      });

      request.fail(function(jqXHR, textStatus) {
        console.log( "Request failed: " + textStatus );
        alert("The request failed. Please close the dialog window and try again.")
      });
    }
  </script>
<% end -%>

<% if flash[:error] -%>
<div class="alert alert-error">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Edit Failed!</strong> <%= flash[:error] %>
</div>
<% end -%>
<% if flash[:notice] -%>
<div class="alert alert-success">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Success!</strong> <%= flash[:notice] %>
</div>
<% end -%>
<table class="table">
  <thead>
    <tr>
      <th>*</th>
      <th>Requester</th>
      <th>Date</th>
      <th>Pickup</th>
      <th>Dropoff</th>
      <th>Phone</th>
      <th>Email</th>
      <th>Notes</th>
    </tr>
  </thead>
  <tbody>
    <% cur_month = nil %>
    <% @data.each do |row| %>
      <% if cur_month.nil? %>
      <% cur_month = row.send_time.strftime("%B") %>
      <tr>
        <td colspan="8" style="text-align: center"><span class="lead"><strong><%= cur_month %></strong></span></td>
      </tr>
      <% elsif cur_month != row.send_time.strftime("%B") %>
      <% cur_month = row.send_time.strftime("%B") %>
      <tr>
        <td colspan="8" style="text-align: center"><span class="lead"><strong><%= cur_month %></strong></span></td>
      </tr>
      <% end %>
      <% if row.send_time.utc < Time.now.utc -%>
      <tr style="background-color:#F5F5F5">
      <% elsif row.removed -%>
      <tr style="background-color:#EE8E8E">
      <% else -%>
      <tr>
      <% end -%>
        <td><%= link_to '<i class="icon-remove"></i>'.html_safe, url_for(:controller => "ems", :action => "delete_scheduled_call", :id =>  row.id.to_s), data: {confirm: "Are you sure you want to delete this scheduled call?"} %>&nbsp;&nbsp;&nbsp;<a href="javascript:editEvent('<%= row.id.to_s %>')"><i class="icon-pencil"></i></a></td>
        <td><%= User.find(row.user_id).email %></td>
        <td><a href="#" title="Send Alert: <%= format_date_calendar_time(row.warning_time, current_user) %>
Place Call: <%= format_date_calendar_time(row.actual_send_time, current_user) %>"><%= format_date_calendar_time(row.send_time, current_user) %></a></td>
        <td><%= row.pickup_address %></td>
        <td><%= row.dropoff_address %></td>
        <td><%= row.notify_phone %></td>
        <td><%= row.notify_email %></td>
        <td><%= simple_format(row.notes) %></td>
      </tr>
    <% end %>
  </tbody>
</table>
<div id="eventDetailModal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="eventDetail" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3>Edit Event Details</h3>
  </div>
  <div class="modal-body">
    <%= form_tag({:controller => :ems, :action => :edit_scheduled_call}, {:method => "post"}) do %>
      <input type="hidden" name="id" value="" id="eventId">
      <label><strong>Pickup Address</strong></label>
      <input type="text" name="pickup_address" id="pickup_address">

      <label><strong>Dropoff Address</strong></label>
      <input type="text" name="dropoff_address" id="dropoff_address">

      <label><strong>Vehicle Type</strong></label>
      <% VehicleType.valid_types.each do |x| %>
        <input type="radio" name="type" value="<%= x %>"><%= x %></br>
      <% end -%>

      <label><br/><strong>Phone</strong></label>
      <input type="text" name="phone" id="phone">

      <label><strong>Email</strong></label>
      <input type="text" name="email" id="email">

      <label><strong>Notes</strong></label>
      <textarea rows="3" name="notes" id="notes"></textarea>

      <label class="control-label" for="send_date"><strong>Date</strong></label>
      <div class="controls">
        <input type="text" name="send_date" id="datepicker">
      </div>
      <label class="control-label" for="send_time"><strong>Time</strong></label>
      <div class="controls">
        <select name="send_hour" class="input-mini" id="send_hour">
          <option value="01">01</option>
          <option value="02">02</option>
          <option value="03">03</option>
          <option value="04">04</option>
          <option value="05">05</option>
          <option value="06">06</option>
          <option value="07">07</option>
          <option value="08">08</option>
          <option value="09">09</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
        </select>:<select name="send_minute" class="input-mini" id="send_minute">
          <option value="00">00</option>
          <option value="05">05</option>
          <option value="10">10</option>
          <option value="15">15</option>
          <option value="20">20</option>
          <option value="25">25</option>
          <option value="30">30</option>
          <option value="35">35</option>
          <option value="40">40</option>
          <option value="45">45</option>
          <option value="50">50</option>
          <option value="55">55</option>
        </select> <input type="radio" name="ampm" value="AM" checked="checked">AM <input type="radio" name="ampm" value="PM">PM
      </div>

      <button type="submit" class="btn">Submit</button>
    <% end %>
  </div>
</div>