lib/generators/cancannible/templates/permission.rb in cancannible-1.0.1 vs lib/generators/cancannible/templates/permission.rb in cancannible-2.0.0

- old
+ new

@@ -1,13 +1,12 @@ # The Permission class stores permissions managed by CanCan and Cancannible class Permission < ActiveRecord::Base belongs_to :permissible, polymorphic: true - belongs_to :resource, polymorphic: true + belongs_to :resource, polymorphic: true, optional: true + validates :ability, uniqueness: { scope: [:resource_id, :resource_type, :permissible_id, :permissible_type] } + # Note: for Rails 3 you may need to declare attr_accessible as follows, depending on your whitelist_attributes setting. # A future version of cancannible should make this unnecessary. # # attr_accessible :asserted, :ability, :resource_id, :resource_type - - validates_uniqueness_of :ability, scope: [:resource_id, :resource_type, :permissible_id, :permissible_type] - -end \ No newline at end of file +end