Skip to content

Remove our String.shorten extension#204

Merged
tom93 merged 1 commit intomasterfrom
replace-string-shorten-with-truncate
Dec 22, 2023
Merged

Remove our String.shorten extension#204
tom93 merged 1 commit intomasterfrom
replace-string-shorten-with-truncate

Conversation

@tom93
Copy link
Contributor

@tom93 tom93 commented Dec 22, 2023

Rails 3 has a built-in truncate method that we can use instead.

Also remove the constant SHORTEN_LIMIT, it is only used in two places and removing it makes it easier to update the configuration.

Suggested-by: @bagedevimo

Review and merge after #203 because of merge conflicts. Done

Edit:

The place that uses it is actually dead code. Updating it anyway, can be deleted separately (draft: #205).

@tom93 tom93 force-pushed the replace-string-shorten-with-truncate branch from 6b9a9ed to 0a28543 Compare December 22, 2023 05:38
Holmes98
Holmes98 previously approved these changes Dec 22, 2023
Copy link
Member

@Holmes98 Holmes98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that truncate(100) returns a string of at most 100 characters, while shorten could return up to 103 characters. But this code is unused anyway, so it doesn't matter.

It's only used in one view, and that view is unused and broken.

And anyway, Rails 3 has a built-in truncate method that we can use
instead.

Suggested-by: Ben Anderson <benanderson@acidic.co.nz>
@tom93 tom93 force-pushed the replace-string-shorten-with-truncate branch from 0a28543 to 63d2cb2 Compare December 22, 2023 06:35
@tom93 tom93 merged commit 9bd2b66 into master Dec 22, 2023
@tom93 tom93 deleted the replace-string-shorten-with-truncate branch December 22, 2023 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants