Showing posts with label update_attribute. Show all posts
Showing posts with label update_attribute. Show all posts

Monday, 7 April 2008

2.0 update or not 2.0 update: Is Rails 2.0 ready yet?

I had a play with converting one of my smaller playthings... er projects over to Rails 2.0 the other day. So far I see no convincing reason to convert yet. There were some small improvements, but I came across a couple of glaring bugs that make rake test incredibly painful to use.

When I find the specific ticket-numbers again I'll include them here, but to briefly describe the issue: The bug caused the setup method not to be called (ever) in unit tests. This meant that tests didn't get their fixtures fresh after every test. The several attempts to fix this issue somehow interfered with another bug that caused the controller not to be loaded in the functional tests.

Both of these situations are so impossible to work with that I'd recommend steering clear of Rails 2.0 for a short while.

I can see it being worthwhile using Rails 2.0 for new/greenfields projects - and putting up with the bugs until the Rails Core Team figure out how to fix them. But I would seriously recommend against it for any pre-existing project - especially one that is currently in a commercial/production environment. The pain of having to convert a complete test-suite over to work around the bugs (or to convert it all over to RSpec) isn't worth the effort just yet.

Conclusion: Yes, but not yet.

Tuesday, 11 December 2007

Rails gotchas: Update attribute... doesn't

Ok, it does... but it doesn't *just* update the attribute - it resaves the whole record. This is a problem if you aren't sure whether or not your record is fresh as you can overwrite other changes with your stale data.

Lesson:

As nasty as it is, you should do a do a self.reload before you do an update_attribute - if it's possible that your record has changed under you (eg by a called sub-method)