Getting hard-drive data into a Rails app: Pre-loading DB table[s] works; how about file access?

Hi,

I’m writing a Bridge (card game) tester for myself and my partner in
order to improve our bidding. I don’t feel like writing a bunch of
SQL Inserts. I could write a Ruby formatter to take data in the
format I like and generate the SQL. Then I’d run feed that file to
the DBMS. That’d be OK.

I’d like it better if I could simply open my file in a controller and,
for each data line, populate a set of attributes of a new model
instance. Is this feasible? Is there a public example of how this
would be coded?

Thanks in Advance,
Richard

On Wed, 2008-08-06 at 16:52 -0700, RichardOnRails wrote:

instance. Is this feasible? Is there a public example of how this
would be coded?


the normal rails way would be to put the data into yml format and then
import the yml file.

http://www.urbanpuddle.com/articles/2007/10/19/load-fixed-data-into-your-rails-app

You could probably use csv type (using faster_csv plugin).

Craig

Hi Craig,

NameBright - Coming Soon

Perfect answer! Many thanks.

Best wishes,
Richard