Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

331
Views
Is there a way to assign a list of numbered variables in a seed file in ruby

I'm trying to create 12 instances of the object list in a seed file, where:

12.times do |i|
list_X = List.create(title: "list #{i +1}" description: Faker::Hipster.paragraph, order_id: order_1.id, user_id: user_1.id)

Problem is that I can't find a way to update X so that it changes on each iteration. I'd like to update it with whatever value i is + 1

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Perhaps like this:

(13..24).each do |i|
  list_X = List.create(title: "list #{i}", #... )
end
over 4 years ago · Santiago Trujillo Report

0

Your code seems like it should be working

12.times do |i|
 p  "list #{i +1}"
end

Results: 
"list 1"
"list 2"
"list 3"
"list 4"
"list 5"
"list 6"
"list 7"
"list 8"
"list 9"
"list 10"
"list 11"
"list 12"
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!