I am using Sinatra and have organized my application into models, views and routes (as suggested here).
I have come across several guides (such as Sinatra Book) on using before filters with routes. Is there any way to use before filters for models?
I am using the Sinatra ActiveRecord extension if it helps.
ActiveRecord has such before filters out-of-the-box.
It supports
before_save,after_save,before_create,after_create, and evenbefore_validationandafter_validation.Look here for a detailed explanation: http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html