这是我模型中的代码:
def to_param
require 'unicode'
"#{id}-#{Unicode::normalize_KD("-"+name+"-").downcase.gsub(/[^[:alnum:]]/,'-')}".gsub(/-{2,}/,'-')
end
我需要unicode
功能,因为在我的某些条目的名称中,它包含重音(外来字符)。如果没有unicode
,则设置为使用-
替换重音字符。
但现在的问题是它给了我以下错误:
ActionView::TemplateError (no such file to load -- unicode) on line #50 of app/views/spots/index.html.erb:
47:
48: <% @shops.each do |spot| %>
49: <div id="<%= dom_id(shop) %>" class="item">
50: <a href="<%= shop_path(shop, :type => @type) %>">
51: <% if !shop.photos.blank? %>
52: <%= image_tag(shop.photos.last.url(:thumb), :class => 'thumbnail') %>
53: <% else %>
我该怎么办?感谢。
答案 0 :(得分:2)
尝试将unicode
gem添加到Gemfile
:
gem 'unicode'