def restrict_to_owner(application, error = false, &block) return unless logged_in? if application.is_owner? current_user p &block p &block.call &block.call elsif error flash[:error] = 'You must be an owner of this application to do that.' redirect_to(application) end end