Code-only improvement: avoiding reimplementing the built in truncate method #1420
Labels
area: ruby
Changes to server-side code
complexity: easy
Issues that should take limited effort to resolve/fix/build.
hacktoberfest
This repo participates in Hacktoberfest. For suitable issues and Hacktoberfest-PRs
meta: good first issue
Good for newcomers
meta: help wanted
Extra attention is needed
priority: low
type: change request
New feature or request
Describe the bug
In the file
app/views/users/_activity_items.html.erb
there are 4 occurrences of truncating a string using a line of code, which has identical behaviour to the built intruncate
method:<%= i.body_plain[0..300] + ((i.body_plain.length > 300) ? "..." : "") %><br>
<%= i.content[0..300] + ((i.content.length > 300) ? "..." : "") %><br>
<%= i.body[0..300] + ((i.body.length > 300) ? "..." : "") %>
<%= i.reason[0..300] + ((i.reason.length > 300) ? "..." : "") %><br>
For example usage of the
truncate
method, seeapp/views/posts/show.html.erb
line 1.We could avoid this duplicated code by replacing these 4 occurrences with calls to
truncate
.The text was updated successfully, but these errors were encountered: