Accounts always start with a "Cards" collection
- Deleting the last collection, immediately creates a new "Cards" collection
This commit is contained in:
@@ -8,4 +8,13 @@ class Collection < ApplicationRecord
|
||||
has_many :events
|
||||
|
||||
scope :alphabetically, -> { order("lower(name)") }
|
||||
|
||||
after_destroy_commit :ensure_default_collection
|
||||
|
||||
private
|
||||
def ensure_default_collection
|
||||
if Collection.count.zero?
|
||||
Collection.create!(name: "Cards")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
class FirstRun
|
||||
def self.create!(user_attributes)
|
||||
user = User.member.create!(user_attributes)
|
||||
|
||||
Account.create!(name: "Fizzy")
|
||||
Closure::Reason.create_defaults
|
||||
User.member.create!(user_attributes)
|
||||
Collection.create!(name: "Cards", creator: user, all_access: true)
|
||||
user
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user