Sebastian,

Since it's an ActiveRecord module that gets included into AR::Base,
you either need to:

1) (Sneaky) Load your own Batches module when AR wants to autoload it
(active_record.rb:51) - override Module#autoload to 'listen' for the
Batches module, and substitute your version (located in /lib or
something) instead. You'll have to do this before Rails loads AR,
though, so put it in /config/preinitializer.rb.

2) (More sane) Monkey-patch the changed methods into AR::B through a
file you include in /lib, /config/initializers or through your own
plugin. You would probably be overriding #find_in_batches,
#sort_batch_rows! and #select_batch_ids.

3) Freeze rails, replace the file. This is the simplest, and least
error-prone, though upgrading and patching Rails may be trickier.

Colin

On Thu, Sep 24, 2009 at 4:47 PM, Sebastian von Conrad
<[email protected]> wrote:
>
> Hi everyone,
>
> I'm trying to find a way to implement a diff I found into my
> application (https://rails.lighthouseapp.com/projects/8994/tickets/
> 2137-allow-find_batches-to-use-order-limit-and-offset). It is
> imperative that I use find_in_batches as well as passing an :order
> option to the function. Certain rows need to be processed before
> others, and because of the size of the table I can't do them all at
> once.
>
> Now, my question is, how could I do this with the least amount of
> fuss? I don't want to edit the batches.rb in my Rails installation, as
> I then would have to do the same on servers and other workstations. I
> also don't particularly want to freeze Rails. I've tried just slapping
> a new batches.rb into /vendor/rails/activerecord/lib/active_record/,
> hoping that that would override just that file, but it doesn't seem to
> work.
>
> Any help would be appreciated!
>
> Best regards,
> Sebastian
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to