From eee6f9f995b74f4e6d5e634b095dd5b5b2c91439 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 12 Oct 2015 15:30:06 -0400 Subject: [PATCH] Fix after_create bug --- app/models/guest_user.rb | 9 +++++++++ app/models/user.rb | 12 +----------- 2 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 app/models/guest_user.rb diff --git a/app/models/guest_user.rb b/app/models/guest_user.rb new file mode 100644 index 0000000..79950bd --- /dev/null +++ b/app/models/guest_user.rb @@ -0,0 +1,9 @@ +class GuestUser + def admin? + false + end + + def moderator? + false + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 458c5c9..00834d1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,7 @@ class User < ActiveRecord::Base rolify - after_create :set_admin, if: User.count == 1 + after_create :set_admin, if: Proc.new { User.count == 1 } def self.create_with_omniauth(auth) where(provider: auth[:provider], uid: auth[:uid]).first_or_create do |user| @@ -26,13 +26,3 @@ class User < ActiveRecord::Base self.add_role :admin end end - -class GuestUser - def admin? - false - end - - def moderator? - false - end -end