I’m building a blog using RoR. I have the index.html.erb page for the posts showing all of the posts. It displays all of the posts and all of their content. I’d like to limit the content that is shown to a certain number of characters and then put a “read more” link to go to the show page for that individual blog post. Any help with how to do this? Thanks.
Share
To show a certain number of characters, you can use truncate helper method to truncate your article.
If you also have question about “read more” link, please read “resource routing” section in Rails Routing from the Outside In. You should show all your posts in
indexaction (probably with pagination), and show single post inshowindex. Truncate the post in theindexview, and show the full post inshowview.