Join Kevin Skoglund for an in-depth discussion in this video Solution: List maker, part of Ruby: Files, Formats, Templates.
(upbeat music)…- [Instructor] In this movie I'm going to show you…a solution that I came up with…for the List Maker challenge, hopefully you were able…to come up with your own solution as well.…Don't worry if it doesn't work exactly the same as mine…but if you ran into problems follow along with me…and I'll show you how it works.…So the very first thing I did was I started working…on this initialize method and I tried to just go through it…step by step, first I tried to locate that list file…in APP_ROOT, so I used File.join with APP_ROOT…and I took the class variable for the filename up here…and just joined those together to get the filepath.…
So then I used file.exists to see if it exists.…If it does exist, then I want to check…and make sure is it readable?…And if it's writable.…So if it's not readable or not writable…the exclamation point in front then I'm going to call abort.…File exists but it's not readable,…file exists but it's not writable.…Now those are unlikely to happen,…but it's good error checking to have it.…
- File system basics
- Writing to and reading from files
- Renaming, deleting, and copying files
- Creating and editing directories
- Working with common data formats
- ERB templating
Skill Level Beginner
Ruby on Rails 5 Essential Trainingwith Kevin Skoglund10h 21m Beginner
1. The File System
2. Work with Files
3. Work with Directories
4. Common Data Formats
5. ERB Templating
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.