• Skip to primary navigation
  • Skip to main content
  • Skip to footer
Code The Dream School
Code the Dream Labs Logo

Code The Dream School

Main hub for class materials for Code the Dream’s classes

  • Code the Dream Home

Search Code The Dream School

Rails Troubleshooting and Active Record Associations

Troubleshooting

The first video is on troubleshooting, here: Troubleshooting Rails. Unfortunately, you won’t be able to duplicate the specific steps the instructor takes, because he does it in a Pets application, which you don’t have, rather than in the blog application you do have. Take some notes. You may also want to put some bogus lines in your blog application to see what kinds of errors occur. For example, in your blog application, you see that the index method in app/controller/posts_controller.rb starts with @posts = Posts.all. What happens if you leave out the @ symbol? In the new method for that same controller, what happens if you put @post = Nonsense.new ? What happens if you put @post = String.new ? What happens with the create method if instead of redirect_to @post , you do redirect_to invalid_path ? What about leaving out the <% end %> in one of the erb files? Do you see how to use the error messages rails reports to find these problems?

The instructor does not mention one very important tool, called byebug. We’ll go through that in a later session.

Active Record Associations

The second video is about Active Record Associations in Rails. For most of this video, you can, and you definitely should, pause the video to duplicate the steps that the instructor is doing so that your version of the blog app matches what the instructor has. However, the instructor does leave the blog app for a time to do many to many associations, with magazine subscriptions and with actors and productions. You won’t be able to duplicate his work for those, but take some notes. You will find this section challenging. Ask questions on our slack channel and in mentor sessions.

Before you start: This lesson involves more changes to the blog application. So, we are going to start using git branches to keep different lessons separate. Before you begin the video, at your command prompt, enter:

git status
git add -A
git commit -m "blog master branch"
git push
git checkout -b associations
git push -u origin associations

As usual, when you have completed the changes to the blog application, push it to github. This will push your changes to the new branch.

Footer

Copyright © 2025 Code the Dream School | All Rights Reserved | Privacy Policy