Accessing methods

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.

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-

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?

i found the solution…

place this at the top of the controller:

helper_method :myMethod

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs