- [Instructor] Now that we know how to access files,…we're ready to learn how to start…writing data to those files.…And fortunately in Ruby,…the process is pretty intuitive.…The first thing we want to do…is we want to access the file.…I'm going to do that using the new method,…but you could also do it using open.…It works the exact same way.…Once I have a file object that I can work with,…then I can call methods on that object.…You'll remember that for output…with the command line we had available to us two methods,…puts and print and we have those available here too.…
But instead of just calling them on their own,…we're going to call them as methods on that file.…So file.puts with whatever string…we want to put in the file,…and file.print with whatever string…we want to print in the file.…And you'll remember on the command line,…the difference between puts and print,…puts automatically adds a line return at the end.…Print does not.…If I want to have a line return…then I need to use double quotes…and use that backslash n as a line return.…
- 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.