You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do we have a wiki to stick this content into? Or maybe we can add it to the README.md?
I thought identifying how to truncate long fields may be useful for others as well.
For large character length fields that you wish to truncate and append ellipse (...), you can utilize the format_with function.
Code example:
class MyEntity < Grape::Entity
format_with(:truncate) { |str| str.truncate(50) }
with_options(format_with: :truncate) do
expose :summary
expose :raw_content
end
end
This will render your content as following when the field is over 50 characters long:
Do we have a wiki to stick this content into? Or maybe we can add it to the README.md?
I thought identifying how to truncate long fields may be useful for others as well.
For large character length fields that you wish to truncate and append ellipse (
...
), you can utilize theformat_with
function.Code example:
This will render your content as following when the field is over 50 characters long:
The text was updated successfully, but these errors were encountered: