Skip to content

Instantly share code, notes, and snippets.

@technicalpickles
Created October 13, 2008 21:16
Show Gist options
  • Save technicalpickles/16605 to your computer and use it in GitHub Desktop.
Save technicalpickles/16605 to your computer and use it in GitHub Desktop.
class DownloadsController < ApplicationController
before_filter :redirect_to_root, :unless => :can_create?, :only => [:new, :create]
before_filter :redirect_to_root, :unless => :can_edit?, :only => [:edit, :update, :destroy]
resources_controller_for :downloads
def redirect_to_root
flash[:notice] = "DENIED!!!11one"
redirect_to root_url
end
helper_method :can_create?, :can_edit?
def can_create?
return !!(current_user && current_user.superuser?)
end
def can_edit?
return !!(current_user && current_user.superuser?)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment