Extending Rails core components like actionpack

I recently edited Rail’s in_place_editor javascript helper along with
Scriptaculous’ inPlaceEditor javascript so that it will accept double or
single clicks (via :double_click => true, if you’re interested). The
only thing I’m worried about is now I have a custom version of Rails
running on my local machine, since I edited the actionpack helper file
directly. Is there anyway to extend the one class Rails which contains
the helper instead of having to worry about a custom Rails file living
in the depths of the Rails installation, and then put this extension in
my application somewhere where it won’t get overwritten on rails
updates?

Nate wrote:

I recently edited Rail’s in_place_editor javascript helper along with
Scriptaculous’ inPlaceEditor javascript so that it will accept double or
single clicks (via :double_click => true, if you’re interested). The
only thing I’m worried about is now I have a custom version of Rails
running on my local machine, since I edited the actionpack helper file
directly. Is there anyway to extend the one class Rails which contains
the helper instead of having to worry about a custom Rails file living
in the depths of the Rails installation, and then put this extension in
my application somewhere where it won’t get overwritten on rails
updates?

You can do just about anything you’d need to do in a plugin. Extract
your mods and package them up as a module that you use to monkey-patch
the class in the Rails component. You can see an example of how to do
that in a plugin here:
http://svn.hasmanythrough.com/public/plugins/dynamic_finders_with_belongs_to_names/


Josh S.
http://blog.hasmanythrough.com

you can also just create ruby files in the lib folder of your rails app,
and these will be loaded up with application. you can put a class in
there with the same name as the helper class you’re changing and put the
modified method in, then that’ll be used instead.