dacd0ee18b
The current approach requires catching exceptions to handle these errors and callers are already handling model validations so it seems more appropriate. Also it seemed to convoluted to add this logic directly to the model since the model needs to check too many possible associations to determine whether or not there are more than one cluster since the model doesn't know what it's being created on. Additionally we only wanted to validate during create to avoid the risk of existing models becoming invalid by many different edge cases.
13 lines
269 B
Ruby
13 lines
269 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Clusters
|
|
class InstancePolicy < BasePolicy
|
|
rule { admin }.policy do
|
|
enable :read_cluster
|
|
enable :add_cluster
|
|
enable :create_cluster
|
|
enable :update_cluster
|
|
enable :admin_cluster
|
|
end
|
|
end
|
|
end
|