Rofb
(Rofb)
November 27, 2009, 7:25pm
1
My server is running Rails 2.3.4...am I not doing this correctly or is
something borked?
c=Contact.last
=> #<Contact id: 24, name: "Larry", email: "larry@gmail.com", phone:
2147483647, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone:
false, hide_email: false>
c.update_attribute('phone',8888888888)
=> true
c
=> #<Contact id: 24, name: "Larry", email: "larry@gmail.com", phone: ,
8888888888, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 19:15:43", hide_name: false, hide_phone:
false, hide_email: false>
Contact.last
=> #<Contact id: 24, name: "Larry", email: "larry@gmail.com", phone:
2147483647, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 19:15:43", hide_name: false, hide_phone:
false, hide_email: false>
I've been tearing my hair out over this..please help.
My server is running Rails 2.3.4...am I not doing this correctly or is
something borked?
>> c=Contact.last
=> #<Contact id: 24, name: "Larry", email: "la...@gmail.com ", phone:
2147483647, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone:
false, hide_email: false>>> c.update_attribute('phone',8888888888)
=> true
>> c
=> #<Contact id: 24, name: "Larry", email: "la...@gmail.com ", phone: ,
8888888888, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 19:15:43", hide_name: false, hide_phone:
false, hide_email: false>>> Contact.last
=> #<Contact id: 24, name: "Larry", email: "la...@gmail.com ", phone:
2147483647, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 19:15:43", hide_name: false, hide_phone:
false, hide_email: false>
Looks like the phone number is getting set to 2^31-1, which might
happen if the data type of the column isn't big enough to hold the
value 8888888888 (personally I keep things like phone numbers as
strings - although it's called a 'phone number' it's not really a
number in that things like leading zeroes, punctuation (eg # to select
someone's extension) are often significant).
Fred
Katherine
(Katherine)
November 27, 2009, 11:42pm
3
Please check if there is attr_accessible on your model.
Add :phone on attr_accessible.