开发者

Can i pass method name as argument with super?

I have created a common controller for my application.

class CommonController < ApplicationController
  def index 
   # My stuff
  end
end

And in my other controller i am using super to call my index method like this.

class Other1Controller < CommonController
  def index
    super
  end
end

class Other2Controller < CommonController
  def index
    super
  end
end

This is working fine.

Now in my class i have two method index and 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

Is there any way ? can开发者_如何学Python i pass method with super to override my method with specific method?


Why not just call index?

class Other1Controller < CommonController
  def index
    super
  end

  def index1
    index
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜