Skip to content

Instantly share code, notes, and snippets.

@DAddYE
Forked from nesquena/example-filters.rb
Created February 20, 2010 00:52
Show Gist options
  • Save DAddYE/309401 to your computer and use it in GitHub Desktop.
Save DAddYE/309401 to your computer and use it in GitHub Desktop.
# 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