Bird
Raised Fist0
Ruby on Railsframework~10 mins

Rails new project generation - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new Rails project named 'blog'.

Ruby on Rails
rails [1] blog
Drag options to blanks, or click blank then click option'
Astart
Bgenerate
Cnew
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'rails generate' instead of 'rails new'.
Using 'rails create' which is not a valid command.
Using 'rails start' which does not create a project.
2fill in blank
medium

Complete the code to create a new Rails project without installing gems immediately.

Ruby on Rails
rails new blog [1]
Drag options to blanks, or click blank then click option'
A--skip-gemfile
B--skip-bundle
C--no-install
D--no-gems
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--no-install' which is not a valid option.
Using '--skip-gemfile' which does not exist.
Using '--no-gems' which is invalid.
3fill in blank
hard

Fix the error in the command to create a new Rails project with PostgreSQL as the database.

Ruby on Rails
rails new blog -d [1]
Drag options to blanks, or click blank then click option'
Apostgresql
Bmysql
Csqlite
Dmongo
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mysql' which is a different database.
Using 'sqlite' which is the default but not PostgreSQL.
Using 'mongo' which is not supported by default.
4fill in blank
hard

Fill both blanks to create a new Rails project named 'shop' with API mode and skip test files.

Ruby on Rails
rails new shop [1] [2]
Drag options to blanks, or click blank then click option'
A--api
B--skip-test
C--skip-test-unit
D--skip-tests
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--skip-test' which is not a valid option.
Using '--skip-tests' which is invalid.
Confusing API mode option with database option.
5fill in blank
hard

Fill all three blanks to create a new Rails project named 'forum' with PostgreSQL, skip Action Mailbox, and skip Action Text.

Ruby on Rails
rails new forum -d [1] [2] [3]
Drag options to blanks, or click blank then click option'
A--skip-action-mailbox
B--skip-action-text
Cpostgresql
D--skip-active-storage
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--skip-active-storage' instead of skipping mailbox or text.
Mixing up the order of options.
Using 'mysql' instead of 'postgresql' for the database.

Practice

(1/5)
1. What does the rails new command do when creating a new project?
easy
A. It only installs Rails without creating any files.
B. It creates a new Rails app with all necessary files and folders.
C. It deletes old Rails projects from your computer.
D. It updates an existing Rails app to the latest version.

Solution

  1. Step 1: Understand the purpose of rails new

    This command is designed to set up a new Rails application by creating all the needed files and folders automatically.
  2. Step 2: Compare options

    Options A, C, and D describe actions unrelated to creating a new project. Only It creates a new Rails app with all necessary files and folders. correctly describes the creation of a new app with files.
  3. Final Answer:

    It creates a new Rails app with all necessary files and folders. -> Option B
  4. Quick Check:

    rails new creates app files = B [OK]
Hint: Remember: rails new sets up a full app folder [OK]
Common Mistakes:
  • Thinking it only installs Rails without files
  • Confusing it with update or delete commands
  • Assuming it modifies existing projects
2. Which of the following is the correct syntax to create a new Rails project named blog with PostgreSQL as the database?
easy
A. rails new blog -d mysql
B. rails create blog --db=postgresql
C. rails generate blog --database=postgresql
D. rails new blog --database=postgresql

Solution

  1. Step 1: Identify the correct command for new project creation

    The command to create a new Rails app is rails new, not rails create or rails generate.
  2. Step 2: Check the database option syntax

    The correct option to specify the database is --database=postgresql. rails new blog -d mysql uses -d mysql which is for MySQL, not PostgreSQL.
  3. Final Answer:

    rails new blog --database=postgresql -> Option D
  4. Quick Check:

    Use rails new with --database= option = C [OK]
Hint: Use rails new appname --database=postgresql for PostgreSQL [OK]
Common Mistakes:
  • Using rails create instead of rails new
  • Wrong database option like -d mysql for PostgreSQL
  • Confusing rails generate with project creation
3. After running rails new shop, which folder will NOT be created inside the new shop directory?
medium
A. app
B. bin
C. node_modules
D. config

Solution

  1. Step 1: Recall default folders created by rails new

    Rails creates folders like app, bin, and config by default for app code, executables, and configuration.
  2. Step 2: Understand node_modules folder creation

    The node_modules folder is created only after installing JavaScript packages with tools like Yarn or npm, not by default with rails new.
  3. Final Answer:

    node_modules -> Option C
  4. Quick Check:

    node_modules appears after JS install, not on new app [OK]
Hint: Default Rails folders exclude node_modules until JS packages installed [OK]
Common Mistakes:
  • Assuming node_modules is created by default
  • Confusing bin with temporary folders
  • Not knowing which folders Rails generates automatically
4. You ran rails new myapp --database=sqlite3 but got an error saying the database adapter is missing. What is the most likely cause?
medium
A. You forgot to install the SQLite3 gem before creating the project.
B. The command rails new does not support SQLite3 database.
C. You must use --db=sqlite3 instead of --database=sqlite3.
D. You need to create the database manually before running rails new.

Solution

  1. Step 1: Understand the error cause

    The error about missing database adapter usually means the required gem (SQLite3) is not installed on the system.
  2. Step 2: Check command and options validity

    The rails new command supports SQLite3 by default with --database=sqlite3. The option --db= is invalid, and manual DB creation is not needed before project creation.
  3. Final Answer:

    You forgot to install the SQLite3 gem before creating the project. -> Option A
  4. Quick Check:

    Missing DB adapter error = missing gem install [OK]
Hint: Install DB gems before rails new to avoid adapter errors [OK]
Common Mistakes:
  • Using wrong option --db= instead of --database=
  • Thinking rails new can't use SQLite3
  • Trying to create DB manually before project
5. You want to create a new Rails project named portfolio with PostgreSQL and skip the default test framework. Which command should you use?
hard
A. rails new portfolio --database=postgresql --skip-test
B. rails new portfolio -d postgresql --skip-test-framework
C. rails new portfolio --database=postgresql --skip-test-framework
D. rails new portfolio -d postgresql --skip-test

Solution

  1. Step 1: Identify correct database option

    The shorthand for --database is -d, but both -d postgresql and --database=postgresql are valid.
  2. Step 2: Identify correct option to skip test framework

    The correct option to skip the default test framework is --skip-test. The option --skip-test-framework is invalid.
  3. Step 3: Combine correct options

    Both rails new portfolio -d postgresql --skip-test and rails new portfolio --database=postgresql --skip-test are valid, but the official documentation prefers the full option --database= with --skip-test.
  4. Final Answer:

    rails new portfolio --database=postgresql --skip-test -> Option A
  5. Quick Check:

    Use --database= for DB and --skip-test to skip tests [OK]
Hint: Use --database= for DB and --skip-test to skip tests [OK]
Common Mistakes:
  • Using invalid option --skip-test-framework
  • Using shorthand -d with wrong skip option
  • Mixing shorthand and wrong skip flags
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard