1. after_create does not get inherited
class Animal < ActiveRecord::Base
after_create :feed_on_milk
def feed_on_milk
self.immunity_level += 1
end
end
class Cat < Animal
end
The after_create does not get inherited, and so our poor little cats won’t get milk! To retain the after_create hook, you’ll need to do:
class Cat < Animal
after_create :feed_on_milk
end
2. after_create is an array of symbols
If you call after_create on same […]
Search
About
You are currently browsing the Deterministic Musings weblog archives for the month November, 2007.
Longer entries are truncated. Click the headline of an entry to read it in its entirety.
Latest
- Cuil indexes 120 billion Web pages, but it forgot to index itself.
- CodeJam@Thoughtworks Beijing
- Don’t be a refactoring bigot (follow-up)
- Services != Distributed Object
- ActiveResource and handling a weird 204 response from a remote rails controller
- Trying out ActiveResource in 3 minutes
- Don’t be a refactoring bigot
- JSON is valid YAML
- A few things I learned about ActiveRecord after_create (and other callbacks)
- TDD is good for your happiness and well-being
