Guest User

Untitled

a guest
Jun 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. # HasForeignLanguage
  2. module HasForeignLanguage
  3. def self.included(mod)
  4. mod.extend(ClassMethods)
  5. end
  6.  
  7. module ClassMethods
  8.  
  9. def has_foreign_language(*args)
  10. args.each do |field|
  11. define_method(field.to_s) do
  12. if I18n.locale != I18n.default_locale
  13. self.send("#{field}_#{I18n.locale}".to_s)
  14. else
  15. super
  16. end
  17. end
  18. end
  19. end
  20.  
  21. end
  22.  
  23. end
Add Comment
Please, Sign In to add comment