Permalink
Browse files

Handle uniqueness checks when there are timestamp fields.

  • Loading branch information...
mcrowe committed Apr 12, 2012
1 parent 6300612 commit 723ac59ac408c9a3ecebd7d66cee8578053e42f8
Showing with 5 additions and 2 deletions.
  1. +3 −2 lib/roleable/user_role.rb
  2. +2 −0 spec/support/shared_contexts.rb
@@ -36,8 +36,9 @@ def with_resource_class(resource_class)
def create_if_unique!(attributes)
user_role = new(attributes)
- record_attributes = user_role.attributes
- record_attributes.delete('id')
+ record_attributes = user_role.attributes.reject do |k, v|
+ %w(id updated_at created_at).include?(k)
+ end
if !exists?(record_attributes) && user_role.save
user_role
@@ -19,6 +19,8 @@
t.integer :role_id
t.integer :resource_id
t.string :resource_type
+
+ t.timestamps
end
model { extend Roleable::UserRole }
end

0 comments on commit 723ac59

Please sign in to comment.