Fix after_create bug
This commit is contained in:
parent
04d6aea297
commit
eee6f9f995
2 changed files with 10 additions and 11 deletions
9
app/models/guest_user.rb
Normal file
9
app/models/guest_user.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class GuestUser
|
||||||
|
def admin?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def moderator?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
rolify
|
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)
|
def self.create_with_omniauth(auth)
|
||||||
where(provider: auth[:provider], uid: auth[:uid]).first_or_create do |user|
|
where(provider: auth[:provider], uid: auth[:uid]).first_or_create do |user|
|
||||||
|
@ -26,13 +26,3 @@ class User < ActiveRecord::Base
|
||||||
self.add_role :admin
|
self.add_role :admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class GuestUser
|
|
||||||
def admin?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def moderator?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in a new issue