Posted about 3 years ago. Visible to the public.

Ruby on Rails basics

Rails is our web framework.

Goals

  • 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
    • has_one, 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

Resources

Exercises

Find your way around an existing app

Let someone help you get the code for makandracards.com.

Have a look around. There will be much you don't understand, yet; 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? What model represents a "card" like this one
  • How are cards associated with our "makandra dev" deck at https://makandracards.com/makandra?
  • 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.

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.

Write your own controller

Using a new or an existing app, create a model and a controller using Rails scaffolds.

Then rewrite it according to the pattern from the chapter "Beautiful Controllers" in our book Growing Rails Applications in Practice (it's in our library).

Which one do you like better? Why?

Movie database (MovieDB)

Write a rails app that lets you manage a list of movies, and a list of actors.
Movies can have multiple actors (and hence and actor starred in multiple movies).

Hint:

  • Keep the interface simple. For example, only allow the user to add a fixed number of actors to a movie at a time.

Owner of this card:

Avatar
Henning Koch
Last edit:
6 months ago
by Florian Leinsinger
Posted by Henning Koch to makandra Curriculum
This website uses cookies to improve usability and analyze traffic.
Accept or learn more