Concatenated fields in a model

Hello RoR community from a newbie!

I have a document number "database" in which each document number
consists of 3 parts: a 2 digit "document category" prefix, a 5 digit
document number, and a 3 digit "document variation" suffix. (I quoted
the word "database" because it is currently stored in a single
spreadsheet). I can export that database to a CSV file and run a
simple rake rule to load the CSV data into a model. (As a sidebar, if
anybody wanted to point me in the direction of how to extract the data
directly from the Excel spreadsheet instead of going through the CSV
pipe first, I would be grateful.)

Traditionally, our documents have been identified as "01-00032-000" or
"20-01017-013", and the data for the document number is stored in 3
columns in the spreadsheet. I can create my model with three separate
columns based on the 3 columns from the spreadsheet, or I can
concatenate them together as shown above. Ultimately, I would like to
be able to display the list of documents grouped by document category
(the 2 digit prefix), and perhaps even limit the display to those
documents that fall into a certain category (00, 01, 02-09, 10-19,
etc...). (As another aside, would I be better off creating a table
identifying names of the 10-12 different categories by min/max
category prefix, or better off coding those names in my specialized
app?)

I started off prototyping a model with the 3 columns separated and
then naively combined them in my view with:

<%=h sprintf("%02d-%05d-%03d", document.document_category_prefix,
              document.primary_document_number,
              document.document_variation) %>

It was quick. It was simple. It tought me that I can embed calls to
'sprintf()' in my view. I went to bed happy.

Today I started investigating active scaffolding so I could get a much
prettier view of the documents than the bare view shown by the default
scaffolding. (I reasoned that, if the interface looks ugly, folks
will think that the implementation is kludgy and buggy, but if it
looks beautiful, they'll think I'm a genios.) (That's a joke, son.)
I quickly ran into the issue of trying to figure out how I would
combine the 3 columns of data in a nice sprintf() output with Active
Scaffolding. The answer to that problem may be trivial, or it may
not, but it quickly led me to my real question:

Should I be combining data like this in a view in the first place? Or
should that go somewhere in the model or controller? If so, how would
I do that? (Asked in the tone of somebody who wrote his first RoR
application last night.)

I would appreciate any wisdom folks would care to share in this matter.

--wpd

Should I be combining data like this in a view in the first place? Or
should that go somewhere in the model or controller? If so, how would
I do that? (Asked in the tone of somebody who wrote his first RoR
application last night.)

Have you looked at composed_of ?

Fred

Have you looked at parseexcel?

http://www.rubyrescue.com/?p=6

Other options: If you're on the Windows Platform, there's win32ole
which can automate excel. If you're on JRuby, you can interface with
POI for excel parsing and creation.

- Mark.