small medium large xlarge

30 Dec 2008, 11:29
Steve Rawlinson (5 posts)

Page 359: “when Rails performs a save it only saves the attributes which have been modified.” This isn’t quite accurate and doesn’t explain why you might want to turn partial updates off or use _will_change. Rails saves attributes which have been changed by direct assignment, but not if they have been modified some other way eg: = 'steve'[0] = 'S'

You have an example of this on page 360 but it’s not actually explained in the text that Rails doesn’t ‘notice’ a change applied by ‘«’ (or anything other than attrib=). There are a lot of post-2.x upgrade questions in forums to which this is the answer and one extra sentence to explain how Rails notices a modified attribute might help.


30 Dec 2008, 14:21
Sam Ruby (633 posts)

How does this sound? I’ll simply add “by direct assignment” to “when Rails performs a save it only saves the attributes which have been modified.” The next page already deals with modifications in place.

31 Dec 2008, 14:46
Steve Rawlinson (5 posts)

That would certainly make that sentence accurate and draw the readers attention to the fact that there might be cases where modifications are not saved.

I now notice the sentence about modifying attributes in place on page 360 and realise that I didn’t actually understand the term ‘modifying in-place’ despite the fact that I was specifically looking for this issue. I may not be representative of your readership (I’m a C programmer and array[x]= is assignment in my world) but the term ‘modifying by any means other than direct assignment of the attribute’ would have been clearer to me than ‘modifying in-place’.

I’ll certainly trust your judgement over mine about what your readers will find easiest to understand and it may be that for most people your wording is just fine.

Incidentally I’ve looked to see if a whole bunch of issues that I’ve had with Rails 2.x have been covered and this is the only one I thought needed any attention. I think the new edition is excellent and you’ve done a fine job.


You must be logged in to comment