One class instance throw all controller

Posted by Falcon on Stack Overflow See other posts from Stack Overflow or by Falcon
Published on 2010-06-06T15:42:22Z Indexed on 2010/06/06 15:52 UTC
Read the original article Hit count: 317

Filed under:
|

Hello i i have different class and controller. and i need that one instance of model will be available in controller/ now i'm doing something like this:

def method1
    inst = @MyClass.new(params)
    inst.action
    ....
def method2
    inst = @MyClass.new(params)
    inst.action
    ....

but i want something like this

def method1    
     @inst.action
    ....
def method2
     @inst.action

or self.inst i't doesn't matter

how i can do it?

def self.inst
    MyClass.new(params)
end

doesn't work...

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby