macOS 10.15.5 Rails 5.2.4.2 Docker 19.03.12
Please see this image. The text of the post displayed on the post list screen, but since the entire text is also displayed on the list screen as it is, it looks very bad like this.
Make this refreshing as follows.
The code before omitting is as follows.
html:index.html.erb
<%= link_to(post.content, "/posts/#{post.id}") %>
Add the ``` truncate method` `` to this code.
html:index.html.erb
<%= link_to post.content.truncate(40), "/posts/#{post.id}" %>
By rewriting in this way, you can omit the display of the character string of the link_to method! This (40) means how many characters to switch to "..." display ^ _ ^
Recommended Posts