All Ruby on Rails quizzes
Intermediate30 questions60 minutes

Ruby on Rails Intermediate Quiz

Explore associations, validations, callbacks, Active Job, Action Cable, and authentication

Start the quiz

Sample questions from this quiz

A preview of the style and depth. Try each one, then reveal the answer — or skip straight to the timed quiz.

1. What are associations?

  • Relationships between models: has_many, belongs_to, has_one
  • Database relations
  • Model relationships
  • Foreign keys
Show answer

Answer: Relationships between models: has_many, belongs_to, has_one. Associations define model relationships. has_many, belongs_to, has_one, has_and_belongs_to_many, has_many :through. Provide convenient methods. Define in model classes.

2. What is belongs_to?

  • Parent reference
  • Child relationship
  • Foreign key
  • Defines one-to-one relationship from child side
Show answer

Answer: Defines one-to-one relationship from child side. belongs_to defines child side: class Post < ApplicationRecord; belongs_to :user; end. Expects user_id foreign key. Provides user method. Singular.

3. What is has_many?

  • Multiple children
  • Parent relationship
  • Collection relationship
  • Defines one-to-many relationship from parent side
Show answer

Answer: Defines one-to-many relationship from parent side. has_many defines parent side: class User < ApplicationRecord; has_many :posts; end. Provides posts collection. Plural. Can add dependent options.

Frequently asked questions

How many questions are in this Ruby on Rails quiz?+

30 questions, with a 60-minute time limit. Every question includes a written explanation of the correct answer.

Is this Ruby on Rails quiz free?+

Yes. Every quiz on CodexQuizz is free and needs no account. You only enter a name if you choose to post your score to the leaderboard.

What level is the intermediate quiz aimed at?+

Explore associations, validations, callbacks, Active Job, Action Cable, and authentication

Can I use this to prepare for a Ruby on Rails interview?+

Yes. The questions cover the topics that come up in Ruby on Rails technical screens, and the explanations are written so that a wrong answer still teaches you the underlying concept.

Ready to test your Ruby on Rails?

30 questions, 60 minutes. Free, no sign-up.

Start now