【发布时间】:2021-09-08 15:21:27
【问题描述】:
嘿,我们是 3 名学生,我们都使用相同的 rails db:seed。我们的项目很好地被 git 拉动和协调,但是..
一个人使用 Linux,rails:db:seed 适合他。
一个人使用 Mac,rails:db:seed 也适用于他。
我,我使用 WSL,但它不起作用! 我已经尝试过 Windows 和 WSL 路径,如下面的屏幕所示。
如果有人可以指导我,谢谢!
config/seed.rb
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
require 'faker'
RealEstate.destroy_all
User.destroy_all
Category.destroy_all
Category.create(title:"House")
Category.create(title:"Flat")
10.times do
u = User.create(email: Faker::Internet.email, password: Faker::Internet.password)
end
30.times do
re = RealEstate.create(
title: Faker::Space.galaxy,
description: Faker::Lorem.paragraph_by_chars(number: 256),
address: Faker::Address.full_address,
location: Faker::Address.city,
price: Faker::Number.number(digits: 8),
user: User.all.sample(),
category: Category.all.sample()
)
re.images.attach(io: File.open(ENV['SAMPLE_IMAGES']), filename: 'sample_image')
end
puts "%" * 50
puts " Base de données remplie !"
puts "%" * 50
【问题讨论】:
标签: ruby-on-rails windows-subsystem-for-linux