generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from ita-social-projects/flipper-migration-fix
added check for flipper table
- Loading branch information
Showing
1 changed file
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |