Usage of methods in application.rb

Hi all,
I’m having some methods in application.rb. I have to use those
methods in my model.
How can i do that?
Thanks in advance.

I think can do like

ins = ApplicationController.new
ins.method_name #method_name is any def in pplication
controller

    But why are you  calling controller methods from model

Sijo

I’d agree with Sijo here - if you need controller models in the model,
something has gone wrong with your design. Either the methods are
really model methods (maybe class methods on the model?), or you’re
trying to do view stuff in the models. Can you post an example of
where you’re running into this problem?

–Matt J.

On Mar 18, 5:52 am, Priya B. [email protected]

Sijo Kg wrote:

I think can do like

ins = ApplicationController.new
ins.method_name #method_name is any def in pplication
controller

    But why are you  calling controller methods from model

Sijo

I need those methods in many places, so i wrote in application.rb. I’m
calling those methods in another method which is in application.rb.

So move such code to lib folder and include those modules where ever you
need using include statement

Sijo

Sijo Kg wrote:

So move such code to lib folder and include those modules where ever you
need using include statement

Sijo

Ya i created a file and moved those methods to lib folder and checked.
Its working fine.

Sijo Kg wrote:

So move such code to lib folder and include those modules where ever you
need using include statement

Sijo

Thank you very much for your good suggestion…