Rails: 如何在另一个控制器中访问 self.method?
Rails: How to access self.method in another controller?
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 框架。我知道继承是一种方式...我想知道其他方式...
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
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 框架。我知道继承是一种方式...我想知道其他方式...
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