Upgrading a legacy app from 1.x to 2.1....
The app has a Product model, and the Products migration contains:
t.column :serial_no, :string, :default => :null
But if I create new, empty Product object like this in script/console:
> p = Product.new
The serial_no field is a string with this value:
> p.serial_no
=> "--- :null\n"
I would have expected nil instead of a string representation of null.
This is causing a slew of tests to break.
Why is this happening in 2.1?
The app uses Postgresql 8.3, if that matters.
Thanks,
Jeff
on 13.08.2008 16:22
on 13.08.2008 16:32
On Aug 13, 2008, at 10:21 AM, Jeff wrote: > Upgrading a legacy app from 1.x to 2.1.... > > The app has a Product model, and the Products migration contains: > > t.column :serial_no, :string, :default => :null You probably mean to have: :default => nil which is the same as not specifying a result. > This is causing a slew of tests to break. You have a symbol :null rather than nil or "null". The YAML serialization you see is a reasonable way to store a Ruby symbol in a database. > Why is this happening in 2.1? > > The app uses Postgresql 8.3, if that matters. > > Thanks, > Jeff You're welcome, -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com
on 13.08.2008 16:46
On Aug 13, 9:31 am, Rob Biedenharn <R...@AgileConsultingLLC.com> wrote: > :default => nil > Ugh... yes, thanks for spotting that. This is a legacy app that I didn't write, but I guess I can simply write a new migration to change the column default. Thanks! Jeff REST with Rails Saturday, Oct 4, 2008 Austin, TX http://www.purpleworkshops.com/workshops/rest-and-web-services