Option 1:
Add a custom method to your model, for example truncated_value , and use this instead:
class Standard < ActiveRecord::Base include ActionView::Helpers::TextHelper def truncated_value truncate(value, :length => 40) end ... ... ... end
Then, in your opinion:
<%= collection_select(:standard, :parent_id, Standard.all, :id, :truncated_value, {:include_blank => 'No Parent'}) %>
Option 2:
Instead, use the select tag instead:
<%= select(:standard, :parent_id, Standard.all.collect{ |s| [truncate(s.value, :length => 40), s.id] }, {:include_blank => 'No Parent'}) %>
source share