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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
Read action: Index6m 31s
-
Read action: Show5m 22s
-
Form basics5m 13s
-
Create action: New4m 54s
-
Create action: Create5m 27s
-
Strong parameters6m 33s
-
Update actions: Edit/update7m 53s
-
Delete actions: Delete/destroy7m 11s
-
Flash hash7m 28s
-
Challenge: Pages and sections CRUD1m 43s
-
Solution: Pages and sections CRUD7m 38s
-
-
-
-
-
-
-
-
-