u = User.new
u.username = Faker::Internet.user_name
u.email = Faker::Internet.email
u.password = "test"
u.password_confirmation = "test"
I am using the Faker gem to load sample data in my app. I have three
models, user, dbase and table.
The table gets created under every dbase so I want it's column 'dbase'
tp have the same value as the dbase.name that was created above.
Please see the code :
u = User.find(id = rand(User.count))
db = Dbase.new
db.name = Faker::Company.name
db.vendor = Faker::Company.name
db.location = [ Faker::Address.city ,
db.port = 50000
db.defuser = u.username
t1 = Faker::Company.name
Table.populate(rand(10)) do |tab|
tab.schema_name = t1
tab.tab_name = Faker::Company.name
tab.dbase = db.name #here it says undefined method `db' for
tab.created_by = Faker::Name.name
tab.created_on = Date.today.to_s
tab.logged = rand(2)
I can accompolish the same using rails console so I am assuming the
console holds the value in cache while this doesn't commit or
Can anyone help on how to accomplish this?