-
-
Save DAddYE/309401 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before/After filters in padrino | |
SimpleApp.controllers :posts do | |
# These are public actions, no authentication required | |
get :index do; ... end; | |
get :show, :with => :id do; ... end; | |
# These actions require being authenticated | |
# Variant 1 | |
before :ensure_user_logged_in!, :for => :authenticated | |
after :log_user_modifications!, :for => :authenticated | |
# Variant 2 | |
group :authenticated, :before => :ensure_user_logged_in!, :after => :log_user_modifications! do | |
# Variant 3 | |
before :ensure_user_logged_in! | |
after :log_user_modifications! | |
post :create do; ... end | |
delete :destroy, :with => :id do; ... end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment