We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3f025b1 commit f979676Copy full SHA for f979676
lib/tasks/translations.rake
@@ -151,11 +151,17 @@ namespace :translations do
151
attribute = row["attribute"]
152
value = row["value"]
153
154
- translation = model_name.translation_class.find_or_initialize_by(
+ translation = model_name.translation_class.find_by(
155
"#{model_name.model_name.singular}_id": model_id,
156
locale: locale
157
)
158
159
+ # fallback translation should be there (create_fallback task), so this is edge case meaning that probably record does not exist
160
+ if translation.nil?
161
+ puts "Translation not found for #{model_name.name} with ID #{model_id} and locale #{locale}."
162
+ next
163
+ end
164
+
165
translation[attribute] = value
166
translation.save!
167
end
0 commit comments