Can someone guide me as to how to update a single attribute/column rather than the whole row in rails 2.0
My table has about 40 columns in it and i have a page that only wants to pull and update about 5 columns not the entire 40
it selects all columns in the listing table and submits them all back upon commit which is pretty uneconomical ie
" UPDATE `listings` SET `classification_id` = 102, `minimum_price` = NULL, `title` = ......... etc
Can someone guide me as to how to update a single attribute/column
rather than the whole row in rails 2.0
My table has about 40 columns in it and i have a page that only wants
to pull and update about 5 columns not the entire 40
That is how AR works currently. You could limit the damage by use
Definitely smells fishy from a data modeling point of view.
What may be more appropriate is to break down your Listing object into
a main class and a one-to-many ListingProperty class. You can create
accessor and mutator delegates for the properties in your main class,
and access them by declaring property accessors in your main class.
It's best to include only frequently accessed and queried columns in
your main class.
Stink, i would have thought an AR update params would have just
updated the params set before the update wether i have 6 or 40
columns.
I think this is how datamapper handles it.
it makes it quite an intense update query if you have for example a
full text column with 1000 words in it.
Thanks for your replies!