title: Adding callbacks for model classes in separate file (RoR)
body: <p>I have a Message model class (which inherits from ActiveRecord::Base). For a particular deployment, I would like to have a separate file which modifies Message by adding a callback. So, instead of doing:</p>
  
  <pre><code># app/models/message.rb
  class Message &lt; ActiveRecord::Base
    before_save :foo
    def foo
       puts 'foo!'
    end
  end
  </code></pre>
  
  <p>I would like to be able to do:</p>
  
  <pre><code># app/models/message.rb
  class Message &lt; ActiveRecord::Base
  end
  
  # config/initializers/fixes.rb
  Message
  class Message
    before_save :foo
    def foo
       puts 'foo!'
    end
  end
  </code></pre>
  
  <p>Problem is, it works when I start the script/console, but when I start it using script/server it <em>usually</em> doesn't. That is the worst part, it isn't that it never works. Sometimes I start the server and it works, sometimes it doesn't, and that is without making any changes to the source. </p>
  
  <p>I am restarting the server itself as (as far as I know) the initializers are run only once and don't get reloaded if modified.</p>
  
  <p>I know the 'sometimes' works is very vague, but I have spent hours here without any luck. Perhaps someone has had a similar issue, or can come up with a different idea to add the callback.</p>