0
0
Ruby on Railsframework~10 mins

Seed data 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 create a new user in the seed file.

Ruby on Rails
User.create(name: "Alice", email: "alice@example.com", [1]: "password123")
Drag options to blanks, or click blank then click option'
Asecret
Bpass
Cpwd
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect attribute names like 'pass' or 'pwd' which Rails does not recognize.
2fill in blank
medium

Complete the code to add multiple products in the seed file.

Ruby on Rails
Product.create([{name: "Book", price: 10}, {name: "Pen", price: [1]])
Drag options to blanks, or click blank then click option'
A15
B0
C5
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero or negative values which might not make sense for price.
3fill in blank
hard

Fix the error in the seed code to correctly create a category.

Ruby on Rails
Category.[1](name: "Electronics")
Drag options to blanks, or click blank then click option'
Amake
Bcreate
Cbuild
Dnew
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'new' which does not save the record to the database.
4fill in blank
hard

Fill both blanks to create users with emails and passwords.

Ruby on Rails
User.create(name: "Bob", email: [1], [2]: "securepass")
Drag options to blanks, or click blank then click option'
A"bob@example.com"
Bpassword
Cpass
D"bob@domain.com"
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the email string or using wrong password attribute names.
5fill in blank
hard

Fill all three blanks to create a product with name, price, and stock quantity.

Ruby on Rails
Product.create(name: [1], price: [2], stock: [3])
Drag options to blanks, or click blank then click option'
A"Laptop"
B999
C50
D"Tablet"
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers with quotes or strings without quotes.