From 0660a12bff8aba7e5ad447d5de004ec7e85903c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Tue, 7 Mar 2023 21:40:01 +0800 Subject: [PATCH] fix error --- app/controllers/admin/property_hires_controller.rb | 6 +----- lib/property_hire/engine.rb | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/property_hires_controller.rb b/app/controllers/admin/property_hires_controller.rb index 41ebbf3..341f6db 100644 --- a/app/controllers/admin/property_hires_controller.rb +++ b/app/controllers/admin/property_hires_controller.rb @@ -128,11 +128,7 @@ class Admin::PropertyHiresController < OrbitAdminController end def settings - if PropertyHireSetting.count == 0 - @settings = PropertyHireSetting.create - else - @settings = PropertyHireSetting.first - end + @settings = PropertyHireSetting.first if request.request_method == "PATCH" @settings.update_attributes(settings_params.except("property_day_settings")) @settings.save diff --git a/lib/property_hire/engine.rb b/lib/property_hire/engine.rb index c5d4288..4860b9b 100644 --- a/lib/property_hire/engine.rb +++ b/lib/property_hire/engine.rb @@ -11,6 +11,13 @@ module PropertyHire authorizable frontend_enabled data_count 1..30 + require File.expand_path('../../../app/models/property_hire_setting', __FILE__) + if defined?(PropertyHireSetting) + if PropertyHireSetting.count == 0 + PropertyHireSetting.create + end + end + if File.basename($0) != 'rake' begin avoid_page_cache HireEmailSet