Jim Jeffers
2005-Nov-10 19:47 UTC
Some of my code Broke after Upgrading from 0.13 to 0.14.3
Some code has stopped working in my model as a result of upgrading to rails rc4. Two things stopped functioning properly in my model after my web- hosts upgraded their rails environment: 1. There is a small percentage of phone numbers that are making it past my before filter. They are coming through with dashes. i.e. ''123-456-7890'' but when I attempt to recreate this the phone number is normalized fine. I''m unsure why 13 or 14 out of 116 new records would pass by the fillter some how? 2. Prior to the upgrade I had redefined read attribute to format all of the attributes to uppercase (thanks to help from people on this list). But now this code is no longer working :( Any ideas? Here is a condensed version of my model: ----------------------------------------- class Member < ActiveRecord::Base before_validation :normalize_phone_number # Fixes the formatting of the phone numer and fax number. def normalize_phone_number self.phone_number.gsub!(/[^\d]/, '''') unless self.phone_number.nil? self.fax_number.gsub!(/[^\d]/, '''') unless self.fax_number.nil? end # Text transforms all strings to uppercase prior to display. def read_attribute(attr_name) a = super(attr_name) if a.respond_to? ''upcase'' then a.upcase else a end end end
Jeremy Kemper
2005-Nov-14 05:09 UTC
Re: Some of my code Broke after Upgrading from 0.13 to 0.14.3
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 10, 2005, at 11:47 AM, Jim Jeffers wrote:> Some code has stopped working in my model as a result of upgrading > to rails rc4. > > Two things stopped functioning properly in my model after my web- > hosts upgraded their rails environment: > > 1. There is a small percentage of phone numbers that are making it > past my before filter. They are coming through with dashes. i.e. > ''123-456-7890'' but when I attempt to recreate this the phone > number is normalized fine. I''m unsure why 13 or 14 out of 116 new > records would pass by the fillter some how? > > 2. Prior to the upgrade I had redefined read attribute to format > all of the attributes to uppercase (thanks to help from people on > this list). But now this code is no longer working :( Any ideas? > > Here is a condensed version of my model: > > ----------------------------------------- > > class Member < ActiveRecord::Base > > before_validation :normalize_phone_number > > # Fixes the formatting of the phone numer and fax number. > def normalize_phone_number > self.phone_number.gsub!(/[^\d]/, '''') unless > self.phone_number.nil? > self.fax_number.gsub!(/[^\d]/, '''') unless self.fax_number.nil? > end > > > # Text transforms all strings to uppercase prior to display. > def read_attribute(attr_name) > a = super(attr_name) > if a.respond_to? ''upcase'' then a.upcase else a end > end > endDoes your code work when you remove the read_attribute override? Try setting ActiveRecord::Base.generate_read_methods = false in environment.rb jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDeBwdAQHALep9HFYRAimzAJ9Sloh8c2S7b8Qs5V6zDVBI9Ot4dgCfXLOa SsZM/r9/KOo5W/oEoCNxAdI=1FgX -----END PGP SIGNATURE-----