Best way: restore a db on a site using an client CSV file

I’m using rails 3.1.1 and ruby 1.9.2+ so CSV is now fasterCSV

I’m also a newb to rails/ruby/web dev…

I have written a site and added functionality to download csv files
from a small database that the site is managing. this is an effort to
add some db backup and restore functionality as i’m not sure i like
the way i’ve figured to do it with heroku using db:push and db:pull…
I could be WAY off on all of this but as i said above: I’m new to all
of it. Just want some security that i can restore the db if i need
to.

i figured out how to download the data (it’s a small db: 3 tables.
largest has 1300 records, smallest has about 20 and doesn’t grow much

  • just the contents change from user interactions). the site is a
    schedule management tool for a volunteer organization that i’m using
    to learn ruby/rails on as a volunteer exercise… win/win

what is the best way to reset the db from my 3 csv files? Currently I
download them and then on my client i cna run a rake method to reset
the db and then load the downloaded files… then i can push the files
up to heroku (where it’s hosted) with “heroku db:push”. this works ok
but it seems kludgy.

my other option would be to do a pull from heroku but then i can’t
mess with the data locally in development and that doesn’t work for me
at all.

i was thinking that i’d like to have the user set the 3 source files
from a form (I have this code in place) and the n have the submit
perform the database reset and then import… there are some
challenges with this:

besided the fact that i don’t know how to do it to begin with: I"d
like to be able to do some validation on the files before the reset /
import… makes me think i have to upload the files, review them, then
(if all is well) preform my reset and then import) does that make
sense?

I’ve read a tiny bit about paperclip - and some other gems like
it… ???
I’ve tried using the CSV library
I’ve tried doing a file upload.

wasn’t able to make any of them work (didn’t try paperclip, just read
up on it)… some problems were due to the articles i was reading were
written before the CSV library changed etc… some just due to lack of
experience.

any ideas or help would be appreciated!

thanks,

max

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs