Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
i18n builder method
def set_contents_builder model_obj
model_name = model_obj.class.name.downcase
accociation = model_obj.send("#{model_name}_contents").group_by {|content| content.lang}
if accociation['ru'].nil?
model_obj.send("#{model_name}_contents").build(lang: 'ru')
end
if accociation['en'].nil?
model_obj.send("#{model_name}_contents").build(lang: 'en')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.