require 'faker'
require 'populator'
require 'date'

Dbase.destroy_all
User.destroy_all
Table.destroy_all

100.times do
  u = User.new
  u.username = Faker::Internet.user_name
  u.email = Faker::Internet.email
  u.password = "test"
  u.password_confirmation = "test"
  u.save
end
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 :

10.times do
    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 ,
Faker::Address.us_state_abbr ].join('.')
    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
main:Object.

      tab.created_by = Faker::Name.name
      tab.created_on = Date.today.to_s
      tab.logged = rand(2)
    end
    db.save
 end

 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
something.

Can anyone help on how to accomplish this?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to