From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Read action: Show

Read action: Show - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Read action: Show

- [Instructor] In this movie, we will learn to implement the show action, which is the other common read action used for CRUD. In the last movie, we used index to return a list of records. One key difference about show is that it's going to require an ID, and that ID must exist in the database. Otherwise rails would return a record not found error. We can't view the details of a record if we can't look it up by ID or if it's not there. Let's add the link to the show page on the index template. We'll be sure to add that ID. In my list of subjects, I already have links for show but they're just place holders at the moment. Let's go into our code and right here where we have link to, show, let's add this URL. Now there are three different ways that we can write this URL since we've defined our resourceful route on it. The first is we could just say subjects and then slash and then inside here we could drop in subject.id, right, that would work. That would generate a URL that had subjects…

Contents