Rails app

71 views
Skip to first unread message

randomu...@gmail.com

unread,
Jan 4, 2008, 8:51:12 AM1/4/08
to Ruby Faker
I'm trying to use the faker gem to put random data in my rails app.
How do I run a ruby script from the command line and have it run
within my rails development environment?

Benjamin Curtis

unread,
Jan 4, 2008, 10:38:11 AM1/4/08
to ruby-...@googlegroups.com
You don't need to go to the command line. Somewhere in your Rails app
you want to "require 'faker'" (assuming the gem is installed) and then
you have access to all the Faker classes, like so: User.create(:name
=> Faker::Name.name)

----
Benjamin Curtis
http://catchthebest.com/ - Recruiting software
http://www.bencurtis.com/ - Personal blog

Chris Barnes

unread,
Jan 4, 2008, 10:45:25 AM1/4/08
to ruby-...@googlegroups.com
Well my idea was to have a demo site up with fake data that would reset itself each night.  I was going to run the script as a cron job.  Is there a ruby way to do the same thing?  Otherwise, I could put the code in my app and once I get a demo database setup, export the sql to rebuild it and re-import it with a cron job.  If I can accomplish this feat and have it all contained in the project without running any cron jobs I would do it that way for portability.
Reply all
Reply to author
Forward
0 new messages