Skip to content

Commit

Permalink
Merge pull request #409 from ita-social-projects/flipper-migration-fix
Browse files Browse the repository at this point in the history
added check for flipper table
  • Loading branch information
loqimean authored May 25, 2023
2 parents 491f87f + 431cfea commit 363f64a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions config/initializers/flipper/flipper_feature.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 363f64a

Please sign in to comment.