Guest User

Untitled

a guest
Jun 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. MODEL:
  2.  
  3. class Book < ActiveRecord::Base
  4. translates :label
  5. end
  6.  
  7. MIGRATION:
  8. class CreateBooks < ActiveRecord::Migration
  9. def self.up
  10. create_table :books do |t|
  11. t.string :name
  12. end
  13. Book.create_translation_table! :name => :string
  14. end
  15. ...
  16.  
  17. I18n.locale = :en
  18. book = Book.new
  19. book.name "Hello"
  20. book.save!
  21.  
  22. I18n.locale = :pl
  23. book.name "Witaj"
  24. book.save!
  25.  
  26. What's in the books table? THE LAST SAVED VALUE! :(
  27.  
  28. So, every new added translation will overwrite original table values.
  29.  
  30. Is it a bug or a feature?
Add Comment
Please, Sign In to add comment