Member-only story
Getting Started With Rails Part 3
Ok after completing part 2 we can now see each article rendered as it was added, however, we now need a way to see a list of articles. The first thing I have done is added a new method to the index articles controller, this method retrieves all of our articles using Article.all.
As we did before; we now create the HTML for index and use the values from @articles to list them.

Here we create a loop using Ruby’s each do loop to render each article in the page, each time we pass through this loop we take one of the articles from the database. As we do this we include the article title, text, and a link to the article itself, this is done by passing it back to the show method we previously made.
Here is the result when visiting our localhost/articles…

Now to add some links so we can navigate around the application, Rails conveniently has a helper method called link_to. I added a link for the new article page in the articles index, a link to the articles list in the welcome index, a return link on the create a new article page, and a return link on each individual article.