On 24 May 2011 20:55, Benjamin Mulaosmanovic
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> Just starting up with rails. I have a textfile with a lot of records in
> the form Name Description.
>
> I would like to put these into my database. What is the quickest and
> best way to do this assuming the database is already set up.
You can write code in db/seeds.rb to read the data and write to the
database (using your ActiveRecord models). Then run
rake db:seed
to run seeds.rb and seed the database from your text file. This will
default to the development db. To seed the production db do
rake RAILS_ENV=production db:seed
Colin
--
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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.