Ruby on rails - Static method

Change your code from

class MyModel
  def checkPings
  end
end

to

class MyModel
  def self.checkPings
  end
end

Note there is self added to the method name.

def checkPings is an instance method for the class MyModel whereas def self.checkPings is a class method.


To declare a static method, write ...

def self.checkPings
  # A static method
end

... or ...

class Myclass extend self

  def checkPings
    # Its static method
  end

end

You can use static methods in Ruby like this:

class MyModel
    def self.do_something
        puts "this is a static method"
    end
end
MyModel.do_something  # => "this is a static method"
MyModel::do_something # => "this is a static method"

Also notice that you're using a wrong naming convention for your method. It should be check_pings instead, but this does not affect if your code works or not, it's just the ruby-style.