我在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
没有做任何事情。我该如何解决这个问题?
感谢。
答案 0 :(得分:2)
link_to中的第二个参数是URL。我想你想要truncate是第一个参数,它是显示给用户的链接文本:
link_to(truncate(shop.web), __URL__, :target => "_blank")