diff options
Diffstat (limited to 'app/policies/application_policy.rb')
| -rw-r--r-- | app/policies/application_policy.rb | 36 | 
1 files changed, 18 insertions, 18 deletions
| diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index e8d7f5f30..b23d9e0cf 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -6,13 +6,25 @@ class ApplicationPolicy      destroy?    end -  # Tie edit and update together, #edit?, do not override #edit?, +  def authorizes_action?(action) +    public_send("#{action}?") +  rescue NoMethodError +    false +  end + +  # Tie edit? and update? together, #edit?, do not override #edit?,    # unless you want to break this tie on purpose    def edit?      update?    end -  # Tie new and create together, do not override #new?, +  # Tie index? and show? together, do not override #new?, +  # unless you want to break this tie on purpose +  def index? +    show? +  end + +  # Tie new? and create? together, do not override #new?,    # unless you want to break this tie on purpose    def new?      create? @@ -39,31 +51,19 @@ class ApplicationPolicy      record.referential if record.respond_to?(:referential)    end -  def index? -    show? -  end - -  def show? -    scope.where(:id => record.id).exists? -  end -    def create?      false    end -  def new? -    create? -  end - -  def update? +  def destroy?      false    end -  def edit? -    update? +  def show? +    scope.where(:id => record.id).exists?    end -  def destroy? +  def update?      false    end | 
