Xcross
Xcross

Reputation: 3

sinatra before/after filter inheritance

Hy!

I have a 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

So e.g. in the OneController i need to run App before block and OneController before block too. Please help! How do I do that?

The super keyword not work.

NoMethodError: super: no superclass method `before (?-mix:)'

Thanks! (Sorry for poor english)

Upvotes: 0

Views: 377

Answers (1)

Uri Agassi
Uri Agassi

Reputation: 37409

You don't need to call super - before is additive - each time you call it you add to the previous calls:

class OneController < App

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

end

Upvotes: 1

Related Questions