# Accessing methods

**URL:** <https://www.ruby-forum.com/t/accessing-methods/107183>\
**Category:** Rails\
**Created:** [June 18, 2007, 10:27pm UTC](https://www.ruby-forum.com/t/accessing-methods/107183 "2007-06-18T22:27:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [June 18, 2007, 10:27pm UTC](https://www.ruby-forum.com/t/accessing-methods/107183/1 "2007-06-18T22:27:51Z")

</div>

I have a method that I want to be able to access from the view and from  
the controller. Where do I put it? If I put it in a helper it works  
for the views but not the controller.

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [June 19, 2007, 12:15am UTC](https://www.ruby-forum.com/t/accessing-methods/107183/2 "2007-06-19T00:15:00Z")

</div>

What the function is doing exactly?  
I guess if it is related to an object, putting it in your model woud  
work. If it is not, then perhaps in the controller?  
Without knowing what does the function it’s hard to get the logic that  
you should apply.

Chewbie

On Jun 18, 3:27 pm, David M. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [June 19, 2007, 12:25am UTC](https://www.ruby-forum.com/t/accessing-methods/107183/3 "2007-06-19T00:25:41Z")

</div>

The functionality of the method is not relevant. I am simply trying to  
better understand the context in which methods can be called and used.

I have a method that needs to be accessed from both the views and the  
controller. Currently if you want to access a method in the views you  
put the method in the helpers. IF you want to access a method in the  
controller you have to put it in the controller.

The question is - how do I access the same method from both the  
controller and the views?

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [June 19, 2007, 1:25am UTC](https://www.ruby-forum.com/t/accessing-methods/107183/4 "2007-06-19T01:25:24Z")

</div>

i found the solution…

place this at the top of the controller:

helper\_method :myMethod
