Reputation: 609
When I use
<%= current_user.name[0,20] %>
it only shows 20 character, as I want.
However, I want to use this approach in another context. I have
<%= @patient.human_attribute_value(:complaints).html_safe %>
and I want to display only [0,20] characters of this, but I didn't manage. I tried
<%= @patient.human_attribute_value(:complaints[0,20]).html_safe %>
but it gives me an error.
Can you please help me?
Upvotes: 3
Views: 53
Reputation: 20033
In your context :complaints
is a symbol that is sent as parameter. Why do you treat it as a property that returns a value?
Try
<%= @patient.human_attribute_value(:complaints)[0,20].html_safe %>
Upvotes: 4