From: Joe OBrien <j...@theedgecase.com>
Date: Tue, 15 Jan 2008 09:15:57 -0500
Local: Tues, Jan 15 2008 9:15 am
Subject: Re: [CRB] Re: Cleaning Currency Values
Bryce,
I create 'getters' or 'setters' and then just use read_attribute, Here is one example. I want to take any of the following string for So I take care of the logic before I store it. I also want to take # :gender is the field name in the database. This provides a hook if validates_inclusion_of :gender, :in => %w{ Male Female Unknown } Hope this helps. -Joe On Jan 15, 2008, at 2:03 AM, Anthony Carlos wrote: > Bryce: -Joe > I guess I should not have said before _filter_. I meant a before > class Blah < AR::Base > before_validation :sanitize_money > def sanitize_money > Sorry about the confusion... It's late! > -Anthony > On Jan 15, 2008, at 1:27 AM, Bryce Thornton wrote: >> Update.. I think this is a better solution: >> def attributes=(attributes, guard_protected_attributes = true) >> super(attributes, guard_protected_attributes) >> It works without changing the way I typically add/update records. >> On Jan 15, 1:12 am, Bryce Thornton <brycethorn...@gmail.com> wrote: >>> def update_cleaned_attributes!(attributes) >>> self.update_attributes!(attributes) >>> I then just call this from my controller instead of >>> Thanks, >>> On Jan 15, 12:56 am, Anthony Carlos <anth...@digitalphenom.com> >>>> Hey Bryce, >>>> I would use a regex to strip out anything that is not a digit or a >>>> input.gsub(/[^0-9.]/, '').to_f >>>> I'm not sure of the "Rails Way," but it seems like a before filter >>>> -Anthony >>>> On Jan 15, 2008, at 12:18 AM, Bryce Thornton wrote: >>>>> I'm trying to figure out how to clean up some form input for a >>>>> My question: how can I sanitize this input data? >>>>> For instance, say the user enters "$115.25". Currently this is >>>> -- >>>> Anthony Carlos > -- > Anthony Carlos _______________ Joe O'Brien, artisan EdgeCase theedgecase.com 614/453-5527 You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||