我正在尋找一種截斷顯示在我的文本中的鏈接的方法。在Rails中查找和截斷文本中的鏈接
Ie: <p><I want to share a link : http://www.itabc.org/wp-content/uploads/2013/10/Tools-for-Ruby-on-Rails-logo.jpg it rocks!</p>
Into : <p>I want to share a link : http://www.itabc.org/wp-con... it rocks!</p>
我想明顯地保持我的href工作。
對我有什麼建議嗎?我想我需要創建一個幫手。
編輯:
文本ins't在我的意見靜態的,我要管理的所發佈消息的用戶的內容,所以我必須找到一個方法來截斷鏈接automaticaly
THX
Rails有截斷helper方法:http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-truncate – Brian