过滤器继承之前/之后的sinatra

时间:2014-05-25 12:57:47

标签: ruby inheritance filter sinatra block

HY!

我有Sinatra App:

class App < Sinatra::Base

  before do

    puts "do something..."

  end

end

class OneController < App

  before do

    super() # Not work

    puts "do something(App before filter) + more..."

  end

end

Sinatra before filter

所以,例如在 OneController 中,我需要在阻止之前运行应用,在阻止之前运行 OneController 。 请帮忙!我该怎么做?

super 关键字不起作用。

  

NoMethodError:super:没有超类方法`之前(?-mix :)&#39;

谢谢! (抱歉英语不好)

1 个答案:

答案 0 :(得分:1)

您无需致电super - before是附加的 - 每次调用它都会添加到之前的通话中:

class OneController < App

  before do
    puts "do something(App before filter) + more..."
  end

end