# First time stepping out of bounds, where does my code go?

**URL:** <https://www.ruby-forum.com/t/first-time-stepping-out-of-bounds-where-does-my-code-go/153676>\
**Category:** Rails\
**Created:** [November 20, 2008, 12:56am UTC](https://www.ruby-forum.com/t/first-time-stepping-out-of-bounds-where-does-my-code-go/153676 "2008-11-20T00:56:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![markbates](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@markbates](https://www.ruby-forum.com/u/markbates)\
**Post date:** [November 20, 2008, 12:56am UTC](https://www.ruby-forum.com/t/first-time-stepping-out-of-bounds-where-does-my-code-go/153676/1 "2008-11-20T00:56:50Z")

</div>

Hey all!

I am about to start drawing outside the lines for the first time, and I  
had a strange question. I have been following the rails conventions  
outlined in my readings and tutorials. I am now working on creating a  
new import feature for my application. The user will upload a PDF which  
will call a script that converts it to a text file.

I have the command line application that will do the conversion, but it  
is my job to start parsing the output into meaningful data that will be  
placed in my database. So after spending some time with my nose buried  
in Ruby books, I feel more then ready to tackle the new challenge, the  
weird thing is . . . where does this code go?

I am going to write a long ruby script that takes the text data and maps  
it out using regular expressions to get the matched up with it’s correct  
labels . . . and I would like to have my own models around to store the  
data in. but it seems like writing the whole thing in one of my  
controllers or models doesn’t seem like the “right” place. While the  
script is running it is going to be saving data to my app’s database,  
and upon completion needs to return some information to my app for  
further processing. Would anyone mind pointing me in the right  
direction?

Thanks ahead of time!

---

<div class="post-metadata">

**Author:** ![markbates](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@markbates](https://www.ruby-forum.com/u/markbates)\
**Post date:** [November 20, 2008, 1:37am UTC](https://www.ruby-forum.com/t/first-time-stepping-out-of-bounds-where-does-my-code-go/153676/2 "2008-11-20T01:37:40Z")

</div>

On Nov 19, 11:56 pm, Mark B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> placed in my database. So after spending some time with my nose buried  
> further processing. Would anyone mind pointing me in the right  
> direction?

You’re instinct to not want it in a controller is good. I personally  
would have it in a model. That model (the DataImporter or whatever you  
want to call it) probably wouldn’t be a subclass of ActiveRecord::Base  
but that’s fine. You could put the corresponding file in the lib  
folder if you don’t like app/models containing non databasey stuff.

Fred
