0
0
Ruby on Railsframework~10 mins

Database table naming conventions 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 name a table for storing user data following Rails conventions.

Ruby on Rails
create_table :[1] do |t|
  t.string :name
  t.timestamps
end
Drag options to blanks, or click blank then click option'
Ausers
Buser
CUser
Duser_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular form like 'user' instead of plural 'users'.
Using camel case like 'User' instead of lowercase.
2fill in blank
medium

Complete the code to name a join table for users and roles in Rails.

Ruby on Rails
create_table :[1], id: false do |t|
  t.references :user
  t.references :role
end
Drag options to blanks, or click blank then click option'
Auser_role
Broles_users
Cuser_roles
Dusers_roles
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular or non-alphabetical order in join table names.
Adding extra words like 'user_role' instead of 'roles_users'.
3fill in blank
hard

Fix the error in the table name to follow Rails conventions.

Ruby on Rails
create_table :[1] do |t|
  t.string :title
  t.timestamps
end
Drag options to blanks, or click blank then click option'
Abooks
Bbook
CBook
DBooks
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular or capitalized table names.
Not pluralizing the table name.
4fill in blank
hard

Fill both blanks to create a migration for a table named correctly and with a primary key.

Ruby on Rails
create_table :[1], [2] do |t|
  t.string :email
  t.timestamps
end
Drag options to blanks, or click blank then click option'
Acustomers
Bprimary_key: :id
Ccustomer
Did: false
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular table names.
Incorrect primary key options like 'id: false' when a primary key is needed.
5fill in blank
hard

Fill all three blanks to define a join table with no id and correct naming.

Ruby on Rails
create_table :[1], [2] do |t|
  t.references :[3]
  t.references :group
end
Drag options to blanks, or click blank then click option'
Agroups_users
Bid: false
Cuser
Dusers_groups
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular or incorrectly ordered join table names.
Forgetting to disable the id column for join tables.