Sam
Sam

Reputation: 5270

How to use truncate helper in rails

How to use truncate helper in rails views for the following text My requirement is

  1. Truncate after 20 letters.(Length = 20)
  2. On the hover of the link, the full text should be displayed

html.erb

<%= link_to sta.device_app.prog_ser.adsp.name, reports_revenue_index_path(:adsp_id => sta.device_app.adsp.id) %>

I tried. But my ideas didn't work out. Thanks

Upvotes: 0

Views: 272

Answers (1)

Ismail Faruqi
Ismail Faruqi

Reputation: 482

I suggest this:

<%= link_to truncate(sta.device_app.prog_ser.adsp.name, :length => 20, :tooltip => sta.device_app.prog_ser.adsp.name), reports_revenue_index_path(:adsp_id => sta.device_app.adsp.id), title: sta.device_app.prog_ser.adsp.name %>

Upvotes: 1

Related Questions