Following the comment from Graeme Mathieson on my last post on Rails-CMDB about the the Rails way for naming of columns within Models. I’m planning on doing the following column rename for the next release of Rails-CMDB:
rename_column :assets, :delivery_date, :delivered_on
rename_column :assets, :removal_date, :removed_onrename_column :locations, :start_date, :started_on
rename_column :locations, :end_date, :ended_onrename_column :purchase_orders,
rder_date,
rdered_on
rename_column :vendors, :last_order_date, :stopped_ordering_on
So the question for the Rails coders out there – does this seem correct ? There’s also a single table who’s primary field is not called name, so I guess to do it in the Rails way it should be changed as well.
I’ve also created about 90 unit test stubs and now just comes the hard part of coding the tests



If it’s just the date (ie day resolution) that’s important then this looks fine. If you’d like the time as well, use eg delivered_at.
By primary field do you meant the primary key? If so, it should always be an auto-incrementing integer ID.
Write your tests first or I’ll have to beat you
By: Craig Webster on August 31, 2007
at 10:08
Craig:
Yes, they are just date fields.
I did not mean the primary key, I was meaning the main context for the data in a table row. In other tables (e.g. purchase_orders, the PO number is stored in the name column). I was thinking that in the hardware table, the field serial_number should be name instead.
As for test, yes I have learned my lesson. Needing to add 90 unit tests, before moving onto functional tests was a mistake. This refactoring will be painful to complete.
I’ll also need to add functional tests for all of the controllers as well. But I’ll fall in that pit when I come to it (i.e. after the unit tests).
By: mrpurpleduck on August 31, 2007
at 18:38