# How to create local subroutines properly in rails?

**URL:** <https://www.ruby-forum.com/t/how-to-create-local-subroutines-properly-in-rails/192617>\
**Category:** Rails\
**Created:** [August 3, 2010, 8:01am UTC](https://www.ruby-forum.com/t/how-to-create-local-subroutines-properly-in-rails/192617 "2010-08-03T08:01:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ct9a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ad7895/32.png) [@ct9a](https://www.ruby-forum.com/u/ct9a)\
**Post date:** [August 3, 2010, 8:01am UTC](https://www.ruby-forum.com/t/how-to-create-local-subroutines-properly-in-rails/192617/1 "2010-08-03T08:01:22Z")

</div>

hi guys,

Using breadcrumbs on rails ([weppos (Simone Carletti) · GitHub](http://github.com/weppos/)  
breadcrumbs\_on\_rails), I have added a method, “set\_breadcrumb” in my  
application controller.

That will set up my home breadcrumb.

In my other feedbacks controller, I have the same “set\_breadcrumb”  
method (in a before\_filter). The breadcrumb added here is called  
“feedback”.

the problem is that when the app runs and I load  
[http://myapp:3000/feedback](http://myapp:3000/feedback),  
I get  
“feedback \> feedback” as the breadcrumb.  
What’s happened is that rails got confused and is looking at the most  
local copy of the “set\_breadcrumb” method.

I think part of the solution is to use a “self.set\_breadcrumb” but  
couldn’t find more to read up on…

My question is, how do we localise a method in a controller such that  
when I call “:before\_filter” in that controller, the local version is  
used, whilst when the application controller calls the same method, it  
uses the copy that is defined in the application\_controller itself?

thanks 🙂
