add a line at the end of spec_helper.rb "include ActionView::Helpers::SanitizeHelper::ClassMethods" 转载于:https://blog.51cto.com/andyss/265810