Proper Location for AR Monkey-Patch (Rails 3)

I’m trying to monkey patch active record (and more specifically the
connection adapter) for a rails 3 app. Here is my attempt:

It doesn’t work. When I try to “rake db:migrate” or open a rails console
otherwise load the app, I get the following error:

alias_method': undefined methodvalue_to_boolean’ for class
`ActiveRecord::ConnectionAdapters::Column’ (NameError)

So, clearly the active record classes (and/or these specific
of active record) aren’t loaded when this initializer runs. So, my
is, given what I’m trying to do, what is the correct or most common way
do this kind of monkey patching? I’m not familiar with the rails 3 way
things but remember hearing/reading a lot about a more standardized way
(API) for configuring/patching/tweaking rails. Is there an idiomatic way
do this properly and at the right time in the application load sequence
I don’t have to have my initializer force-preload these AR classes)?

Thanks in advance for any input!

Okay, I did an edit of my linked monkey-patch. I can do a “rake
and start a rails console now. I fixed on obvious bug I had. However,
forced to manually include the mysql adapter in my initializer for it to
work. So, my overall question still stands… what is the correct
way of doing this?

Side note: though I can now run my migration(s) and load a console, the
database table created with my migration doesn’t seem to reflect my
monkey-patching (yes, I did a complete “rake db:drop” first). In other
words, if anyone also has more specific pointers (not just how/where to
monkey-patch like this, but how to accomplish my specific goal) I’d sure
welcome them. Just so you know, I’m trying to force the AR/MysqlAdapter
use “-1” for boolean true values and the MySQL “TIMESTAMP” type for
:timestamp-typed columns.

Thanks again.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs