0
0
Ruby on Railsframework~10 mins

Controller generation in Ruby on Rails - Interactive Code Practice

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

Complete 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'
Acontroller
Bmodel
Cmigration
Dscaffold
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.
2fill in blank
medium

Complete 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'
Ashow
Bedit
Cindex
Ddelete
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.
3fill in blank
hard

Fix 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'
Anew
Bnew create
Ccreate
Attempts:
3 left
💡 Hint
Common Mistakes
Putting multiple actions in one blank causes syntax errors.
Not providing both actions separately.
4fill in blank
hard

Fill 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'
Ashow
Bindex
Cedit
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up action names or combining them in one argument.
Using invalid action names.
5fill in blank
hard

Fill 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'
Ashow
Bcreate
Cdestroy
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Combining multiple actions in one argument.
Using actions not relevant to the controller.