# Overriding ActionController method in an app

**URL:** <https://www.ruby-forum.com/t/overriding-actioncontroller-method-in-an-app/130768>\
**Category:** Rails\
**Created:** [March 3, 2008, 6:45am UTC](https://www.ruby-forum.com/t/overriding-actioncontroller-method-in-an-app/130768 "2008-03-03T06:45:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![garrettmurray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ce7236/32.png) [@garrettmurray](https://www.ruby-forum.com/u/garrettmurray)\
**Post date:** [March 3, 2008, 6:45am UTC](https://www.ruby-forum.com/t/overriding-actioncontroller-method-in-an-app/130768/1 "2008-03-03T06:45:38Z")

</div>

i can’t seem to get this working… basically, i want to use a patch  
that was added to rails:

[http://dev.rubyonrails.org/changeset/8785](http://dev.rubyonrails.org/changeset/8785)

but i don’t want to have to upgrade past 2.0.2, and i don’t want to  
have to freeze rails inside the app.

so i was hoping to override the methods in ActionController required  
to make the patch to my app only. i created a file called  
‘path\_patch.rb’ and put it in my config/initializers dir, which  
contains the following:

ActionController::Resources::Resource.class\_eval do  
attr\_reader :path\_segment

def initialize(entities, options)  
@plural ||= entities  
@singular ||= options[:singular] || plural.to\_s.singularize  
@path\_segment = options.delete(:as) || @plural

```
@options = options

arrange_actions
add_default_actions
set_prefixes

```

end

def path  
@path ||= “#{path\_prefix}/#{path\_segment}”  
end

end

but it doesn’t work. and, actually, no matter how hard i try (using  
this or other code) i can’t seem to override the path method, even to  
just cause it return bogus info.

help!

TIA
