# Editing POST info before adding to the DB

**URL:** <https://www.ruby-forum.com/t/editing-post-info-before-adding-to-the-db/127423>\
**Category:** Rails\
**Created:** [January 29, 2008, 1:54am UTC](https://www.ruby-forum.com/t/editing-post-info-before-adding-to-the-db/127423 "2008-01-29T01:54:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [January 29, 2008, 1:54am UTC](https://www.ruby-forum.com/t/editing-post-info-before-adding-to-the-db/127423/1 "2008-01-29T01:54:44Z")

</div>

Hello,  
I have a script that parses a CSV during POST and pops the data into my  
MySQL db. It works great, but I want to edit some info from the CSV  
before I put it into the DB. In my case, I need to strip off the leading  
number off of strings are 11 characters in length. I was recommended  
that I do this in the model… I’m not exactly sure how to do this…  
What I have is this in my model:

class Bes \< ActiveRecord::Base  
def besnumber  
if bes.bes\_phonenumber.to\_s.size == 11  
bes.bes\_phonenumber = bes.bes\_phonenumber.to\_s.slice(1…11)  
end  
end  
end

However, after I upload it and check the database, the numbers haven’t  
been cut. How exactly does this MVC work? I mean, does it go from the  
index view to the model then to the controller? Wouldn’t I then want to  
put this in the controller? I am very new to RoR and any help is  
appreciated!

Thanks,

- Jeff M.

---

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [January 29, 2008, 3:01am UTC](https://www.ruby-forum.com/t/editing-post-info-before-adding-to-the-db/127423/2 "2008-01-29T03:01:07Z")

</div>

nevermind, I got it done inside the controller. Thanks anyway!
