On Wed, Nov 04, 2009 at 09:59:36PM +0000, Colin Law wrote:
> What is wrong with storing it as a string anyway?
Strings are less efficient than integers, from a database point of view.
More importantly, though, if you store a number as varchar or text, you
have a much harder time regularizing the output. For example, you
couldn't do this:
>> foo = ActionView::Base.new
>> foo.number_to_phone 1234567890, :area_code => true
=> "(123) 456-7890"
with a random string. If you try, you just get back the original string,
like so:
>> foo.number_to_phone "123/456.7890x55", :area_code => true
=> "123/456.7890x55"
The whole idea here is to regularize the data IN THE DATABASE, so that
the output can be customized (and perhaps even changed later) without
having to change the schema. Isn't there some way to strip out the
characters and extra digits *after* form submission but *before* the
assignment to the model object?
--
"Oh, look: rocks!"
-- Doctor Who, "Destiny of the Daleks"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---