From 431cfea16285c20257f577f2d209448ad5fbb085 Mon Sep 17 00:00:00 2001 From: annakynutsya Date: Sat, 13 May 2023 15:04:44 +0300 Subject: [PATCH] added check for flipper table --- .../initializers/flipper/flipper_feature.rb | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/config/initializers/flipper/flipper_feature.rb b/config/initializers/flipper/flipper_feature.rb index 8230089ea..3a94ca396 100644 --- a/config/initializers/flipper/flipper_feature.rb +++ b/config/initializers/flipper/flipper_feature.rb @@ -1,16 +1,20 @@ -class Flipper::Feature - delegate :en_description, :en_description=, to: :feature_record - delegate :uk_description, :uk_description=, to: :feature_record +if Flipper::Adapters::ActiveRecord::Feature.table_exists? + class Flipper::Feature + delegate :en_description, :en_description=, to: :feature_record + delegate :uk_description, :uk_description=, to: :feature_record - alias_method :name, :key + alias_method :name, :key - def description - public_send("#{I18n.locale}_description") - end + def description + public_send("#{I18n.locale}_description") + end - private + private - def feature_record - @feature_record ||= Flipper::Adapters::ActiveRecord::Feature.find_or_create_by(key: key) + def feature_record + @feature_record ||= Flipper::Adapters::ActiveRecord::Feature.find_or_create_by(key: key) + end end +else + raise ActiveRecord::PendingMigrationError end