Ruby on Rails Saturday, January 26, 2019

> On Jan 26, 2019, at 5:27 PM, fugee ohu <fugee279@gmail.com> wrote:
>
> TypeError: no implicit conversion of Symbol into Integer
> from app/models/press_release.rb:17:in `truncated_headline'
>
>
> class PressRelease < ApplicationRecord
>
> extend FriendlyId
> friendly_id :truncated_headline, use: :slugged
>
>
> def truncated_headline
> # cut off at 200 characters, without an ellipsis
> headline.truncate(255, '')
> end
>

Aha. truncate takes named arguments past the first one. The correct signature is

headline.truncate(255, omission: '')

This should work.

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8D6F2BBA-54B6-45EA-998E-ABD1AF7D3D6B%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment