Tuesday, May 24, 2011

Re: [Rails] Simple database question

On 24 May 2011 20:55, Benjamin Mulaosmanovic <lists@ruby-forum.com> 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate