Ruby on rails - Static method

后端 未结 6 496
青春惊慌失措
青春惊慌失措 2020-12-09 07:31

I want a method to be executed every 5 minutes, I implemented whenever for ruby (cron). But it does not work. I think my method is not accessible. The method I want to exec

6条回答
  •  [愿得一人]
    2020-12-09 08:03

    There are some ways to declare a static method in RoR.

    #1

    class YourClassName
      class << self
        def your_static_method (params)
          # Your code here
        end
      end
    end
    

    #2

    class YourClassName
      def self.your_status_method
        // Your code here
      end
    end
    

提交回复
热议问题