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

**URL:** <https://www.ruby-forum.com/t/getting-hard-drive-data-into-a-rails-app-pre-loading-db-table-s-works-how-about-file-access/145234>\
**Category:** Rails\
**Created:** [August 7, 2008, 1:53am UTC](https://www.ruby-forum.com/t/getting-hard-drive-data-into-a-rails-app-pre-loading-db-table-s-works-how-about-file-access/145234 "2008-08-07T01:53:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [August 7, 2008, 1:53am UTC](https://www.ruby-forum.com/t/getting-hard-drive-data-into-a-rails-app-pre-loading-db-table-s-works-how-about-file-access/145234/1 "2008-08-07T01:53:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [August 7, 2008, 3:48am UTC](https://www.ruby-forum.com/t/getting-hard-drive-data-into-a-rails-app-pre-loading-db-table-s-works-how-about-file-access/145234/2 "2008-08-07T03:48:29Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [August 7, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/getting-hard-drive-data-into-a-rails-app-pre-loading-db-table-s-works-how-about-file-access/145234/3 "2008-08-07T14:46:59Z")

</div>

Hi Craig,

> [NameBright - Coming Soon](http://www.urbanpuddle.com/articles/2007/10/19/load-fixed-data-into-y)

Perfect answer! Many thanks.

Best wishes,  
Richard
