Skip to content

Commit

Permalink
Do not warn about table conflict if table(s) do not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
shioyama committed Oct 2, 2016
1 parent 3ec6706 commit 5a41f9f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/globalize/active_record/act_macro.rb
Expand Up @@ -4,8 +4,8 @@ module ActMacro
def translates(*attr_names)
options = attr_names.extract_options!
# Bypass setup_translates! if the initial bootstrapping is done already.
check_columns!(attr_names)
setup_translates!(options) unless translates?
check_columns!(attr_names)

# Add any extra translatable attributes.
attr_names = attr_names.map(&:to_sym)
Expand Down Expand Up @@ -47,14 +47,15 @@ def allow_translation_of_attributes(attr_names)
end

def check_columns!(attr_names)
# If tables do not exist, do not warn about conflicting columns
return unless table_exists? && translation_class.table_exists?

if (overlap = attr_names.map(&:to_s) & column_names).present?
ActiveSupport::Deprecation.warn(
["These columns are present in both model and translation tables of #{model_name}: #{overlap.join(', ')}\n",
"Globalize does not support this configuration, expect problems."].join
)
end
rescue ::ActiveRecord::StatementInvalid
warn "Model missing a table: #{model_name}"
end

def apply_globalize_options(options)
Expand Down

0 comments on commit 5a41f9f

Please sign in to comment.