Ruby 报错记录

记录使用 ruby 脚本过程中报错信息

Encoding::UndefinedConversionError: “\xE4” from ASCII-8BIT to UTF-8

文件读写时需要强制转换成 utf-8

require 'net/http'

url = ""'1.html', "w:UTF-8") do |f|
  content = Net::HTTP.get_response(URI.parse(url)).body


ActiveRecord::SubclassNotFound (The single-table inheritance mechanism failed to locate the subclass: ‘G6’. This error is raised because the column ‘type’ is reserved for storing the class in case of inheritance. Please rename this column if you didn’t intend it to be used for storing the inheritance class or overwrite Cy::Photo.inheritance_column to use another column for that information.)

在相关model中加入self.inheritance_column = nil即可,如: