Sha256: c5bee3d4ba05ff4849ed9add93b7889a621ca5b94cd72289e0914619fb191304

Contents?: true

Size: 671 Bytes

Versions: 4

Compression:

Stored size: 671 Bytes

Contents

# Authorization for <%= options[:name] %> objects
class <%= options[:name].camelize %>Policy < ApplicationPolicy
  # Allow all users to access new <%= options[:name] %>
  def new?
    true
  end

  # Allows owner to edit <%= options[:name].camelize %>
  def edit?
    user == record.user
  end

  # Allows all users to create <%= options[:name].camelize %>
  alias_method :create?, :new?

  # Allows all users to view <%= options[:name].camelize %>
  alias_method :show?, :new?

  # Allows owner to update an <%= options[:name].camelize %>
  alias_method :update?, :edit?

  # Allows owner to remove an <%= options[:name].camelize %>
  alias_method :destroy?, :edit?
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
myrails-6.0.0 lib/myrails/templates/rails/app/policies/pundit.rb
myrails-5.0.0 lib/myrails/templates/rails/app/policies/pundit.rb
myrails-4.0.0 lib/myrails/templates/rails/pundit.rb
myrails-3.2.1 lib/myrails/templates/rails/pundit.rb