Ruby on rails 在辅助对象内截断

Ruby on rails 在辅助对象内截断,ruby-on-rails,Ruby On Rails,我在Rails 3中有以下助手: def other_contact_info(shop = false) shop = shop ? shop : @shop email = mail_to(shop.email, "Email", :encode => "javascript") if shop.web.present? web = link_to(shop.web, truncate(shop.web), :target => "_blank") if shop.w

我在Rails 3中有以下助手:

def other_contact_info(shop = false)
  shop = shop ? shop : @shop
  email = mail_to(shop.email, "Email", :encode => "javascript") if shop.web.present?
  web = link_to(shop.web, truncate(shop.web), :target => "_blank") if shop.web.present?
  raw [shop.contact, email, web].select(&:present?).join(" · ")
end
truncate
没有任何作用。我怎样才能解决这个问题


谢谢。

链接中的第二个参数是URL。我认为您希望truncate位于第一个参数上,该参数是显示给用户的链接文本:

link_to(truncate(shop.web), __URL__, :target => "_blank")