截断 link_to Rails 上的助手 [英] Truncate helper on a link_to Rails

查看:49
本文介绍了截断 link_to Rails 上的助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当然可以使用 truncate helper 在 rails 中截断 link_to,我的应用程序中有这个 link_to

Is it possible to truncate a link_to within rails using the truncate helper of course, I have this link_to in my app

<%= link_to b.bookname, b %>

这是在一个 .each 内,所以我正在通过 b,例如

This is within a .each do so i am passing through b for example

搞砸了一些变化,但目前无法开始工作,

messed around with a few variations but unable to get to work at present,

以前有人这样做过吗?

谢谢

推荐答案

使用 truncate 帮手

<%= link_to truncate(b.bookname, :length => 5), b %>

这篇关于截断 link_to Rails 上的助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆