我可以将方法名称作为参数传递给super吗?

kru*_*hah 0 ruby ruby-on-rails

我为我的应用程序创建了一个通用控制器.

class CommonController < ApplicationController
  def index 
   # My stuff
  end
end
Run Code Online (Sandbox Code Playgroud)

在我的另一个控制器中,我使用super来调用我的索引方法.

class Other1Controller < CommonController
  def index
    super
  end
end

class Other2Controller < CommonController
  def index
    super
  end
end
Run Code Online (Sandbox Code Playgroud)

这工作正常.

现在在我的班级我有两个方法索引和index1.

class Other1Controller < CommonController
  def index
    super
  end

  def index1
    super(index) # Can i pass method inside super to override this method with my 
                 # common index method.
  end
end
Run Code Online (Sandbox Code Playgroud)

有什么办法吗?我可以用super传递方法用特定方法覆盖我的方法吗?

mip*_*adi 5

为什么不打电话index

class Other1Controller < CommonController
  def index
    super
  end

  def index1
    index
  end
end
Run Code Online (Sandbox Code Playgroud)