switch install state to db
This commit is contained in:
@@ -57,6 +57,6 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def setup_completed?
|
||||
File.exist?(Rails.root.join(".installed"))
|
||||
SetupState.installed?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class SetupController < ApplicationController
|
||||
@user.invitation_accepted_at = Time.current
|
||||
|
||||
if @user.save
|
||||
create_installed_marker
|
||||
SetupState.mark_installed!
|
||||
session[:user_id] = @user.id
|
||||
redirect_to admin_root_path, notice: "Setup complete! Welcome to Sanasto Wiki."
|
||||
else
|
||||
@@ -28,15 +28,7 @@ class SetupController < ApplicationController
|
||||
end
|
||||
|
||||
def setup_completed?
|
||||
File.exist?(installed_marker_path)
|
||||
end
|
||||
|
||||
def installed_marker_path
|
||||
Rails.root.join(".installed")
|
||||
end
|
||||
|
||||
def create_installed_marker
|
||||
FileUtils.touch(installed_marker_path)
|
||||
SetupState.installed?
|
||||
end
|
||||
|
||||
def user_params
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
class SetupState < ApplicationRecord
|
||||
def self.installed?
|
||||
first&.installed? || false
|
||||
end
|
||||
|
||||
def self.mark_installed!
|
||||
record = first_or_initialize
|
||||
record.installed = true
|
||||
record.installed_at ||= Time.current
|
||||
record.save!
|
||||
end
|
||||
|
||||
def self.reset!
|
||||
delete_all
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user