Rails:如何在另一个控制器中访问self.method?

时间:2016-01-07 14:44:40

标签: ruby-on-rails ruby controller action

class Foo1
  def self.foo1action(cake)
    # returns user object
  end
end

class Foo2
  def foo2action
    user = # here i want call foo1action
  end
end

如何在foo2action中调用foo1action? 这基于rails框架。我知道继承是一种方法......我想知道其他方式这样做..

1 个答案:

答案 0 :(得分:2)

class Foo1
  def self.foo_1_action(cake)
  end
end

class Foo2
  def foo_2_action
    user = ::Foo1.foo_1_action(some_cake)
  end
end