Header_image
Jeremy Walker

Software Developer & Social Entrepreneur

The old APIs for excerpt, word_wrap and highlight are deprecated

Seeing any of these messages in your Ruby on Rails 3.2 application?

  • Calling excerpt with radius and omission as arguments is deprecated.
  • Calling word_wrap with line_width as an argument is deprecated.
  • Calling highlight with a highlighter as an argument is deprecated.
I have just deprecated the old text helper API functionality that allowed you to pass optional arguments to these functions. Instead you need to use new options hash syntax that has been avaliable for a while.


highlight('You searched for: rails', 'rails', '\1')
# should be changed to:
highlight('You searched for: rails', 'rails', :highlighter => '\1')

excerpt('This is also an example', 'an', 8, ' ')
# should be changed to:
excerpt('This is also an example', 'an', :radius => 8, :omission => ' ')

word_wrap('Once upon a time', 8)
# should be changed to:
word_wrap('Once upon a time', :line_width => 8)

The old syntax will stop working in Rails 4 so update your application now to avoid one less headache in a few months!

Share This Post

Comments

No-one has posted a comment yet. Be the first!

Post a Comment

I'd love to hear your thoughts :)