Skip to content

Instantly share code, notes, and snippets.

@bkaney
Created December 10, 2008 19:04
Show Gist options
  • Save bkaney/34441 to your computer and use it in GitHub Desktop.
Save bkaney/34441 to your computer and use it in GitHub Desktop.
Index: lib/plugins/acts_as_asset/lib/everyone.rb
===================================================================
--- lib/plugins/acts_as_asset/lib/everyone.rb (revision 5414)
+++ lib/plugins/acts_as_asset/lib/everyone.rb (working copy)
@@ -17,11 +17,15 @@
# in the database for 'Everyone' -- this will allow referential integrity to be maintained
# when ACL records reference 'Everyone'
Asset.connection.execute("INSERT INTO assets(id, asset_type) VALUES(#{ID},'Everyone')");
+ # Sometimes within the context of a transaction, the finder was returning nil
+ # from the Everyone.find_by_id, so creating and object with the same data....
+ @@instance = Everyone.find_by_id(ID)
+ @@instance = Asset.new(:id => ID, :asset_type => 'Everyone') unless @@instance
end
- @@instance = Everyone.find_by_id(ID)
else
@@instance
end
+ return @@instance
end
def initialize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment