Posted over 6 years ago. Visible to the public.

Ruby on Rails basics [4d]

Rails is our web framework.


  • Be able to write a simple Rails application.
  • Understand how Rails talks to the database (ActiveRecord)
    • What is a model?
    • How are records retrieved and saved?
    • Validations
    • Migrations
    • belongs_to, has_many, has_many :through
  • Gain an understanding of the structure of a basic Rails app
    • Routes
    • Controllers
      • Generate a controller using Rails scaffolding
      • Write your own controller
    • Views
      • using ERB
    • Models
    • Helpers
  • Learn how to do CRUD ("Create", "Read", "Update", "Destroy")
    • How to show a list of existing database records
    • How to build a user interface to show and update database records



Find your way around an existing app

Let someone help you get the code for

Have a look around. There will be much you don't understand yetM AND THAT'S ok. don't lose yourself in the details.

Try to see if you can understand a few basic things in the code:

  • What are the important models? For instance, what model represents a "card" like this one
  • How are cards associated with our "makandra dev" deck at
  • Where is the form to update a card? The controller? The view?
  • There is a feature to "repeat cards", that brings random "repeating cards" to the top of the deck, once a week. Search for "repeating", and see if you understand what's happening.

Rails tutorial

Work through the Ruby on Rails Tutorial Archive except for chapters 4.2 - 4.4, 9, 11 and 12.

For each chapter:

  • You should do all the programming exercises.
  • You can skip the testing exercises. There will be a later card to learn testing. We're also mostly using different testing frameworks and writing different types of tests than the tutorial.
  • You can also skip the chapter "1.3 Version control with Git" and all deploying steps

Movie database

Write a Rails app that manages a list of movies and a list of actors. We will call this app "MovieDB" in subsequent cards.

Movies can have multiple actors (and hence an actor can star in multiple movies). The user should be able to create a new movie/actor association from a movie's show view.

Your application layout should have a navigation bar to switch between sections (movies, actors).

We will use Rails 6 for our MovieDB. Create your new application like this:

gem install rails --version="~>6.0" rails new movie-db --skip-turbolinks


  • Use a join model Archive like Role or Casting to associate actors with the movies they star in. A movie's show view should link to associated actors. An actor's show view should link to associated movies.
  • If you generate any code with scaffolding, you must understand every line of the generated code. Also delete any generated code that is not required for your application.

Write your own controller

Refactor your MovieDB controlls to the pattern in our book Growing Rails Applications in Practice Archive (chapter "Beautiful Controllers").

The book is in our library.

Owner of this card:

Henning Koch
Last edit:
9 months ago
by Henning Koch
Posted by Henning Koch to makandra Curriculum
This website uses short-lived cookies to improve usability.
Accept or learn more