Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to generate a new controller named 'Posts'.
Ruby on Rails
rails generate [1] Posts Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'model' instead of 'controller' will generate a model, not a controller.
Using 'migration' creates a database migration, not a controller.
✗ Incorrect
Use controller to generate a new controller in Rails.
2fill in blank
mediumComplete the code to generate a controller with an action named 'index'.
Ruby on Rails
rails generate controller Posts [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'show' or 'edit' will create different actions, not the list action.
Using 'delete' is not a valid action name for generation.
✗ Incorrect
The index action is commonly used to list all records.
3fill in blank
hardFix the error in the command to generate a controller named 'Users' with actions 'new' and 'create'.
Ruby on Rails
rails generate controller Users [1] [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting multiple actions in one blank causes syntax errors.
Not providing both actions separately.
✗ Incorrect
Each action must be a separate argument; you cannot combine them in one option.
4fill in blank
hardFill both blanks to generate a controller named 'Articles' with actions 'show' and 'edit'.
Ruby on Rails
rails generate controller Articles [1] [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up action names or combining them in one argument.
Using invalid action names.
✗ Incorrect
Actions are listed separately after the controller name.
5fill in blank
hardFill all three blanks to generate a controller named 'Comments' with actions 'create', 'destroy', and 'update'.
Ruby on Rails
rails generate controller Comments [1] [2] [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Combining multiple actions in one argument.
Using actions not relevant to the controller.
✗ Incorrect
List all desired actions separately after the controller name.