test/support/models/news.rb in translatable-0.3.1 vs test/support/models/news.rb in translatable-1.2.2
- old
+ new
@@ -1,17 +1,14 @@
-require 'active_record'
-require 'translatable'
-
class CreateNewsTables < ActiveRecord::Migration
def up
create_table(:authors) do |t|
t.string :name, :null => false
t.timestamps
end
- create_table(:translatable_news) do |t|
+ create_table(:translated_news) do |t|
t.string :title, :null => false
t.string :content, :null => false
t.integer :origin_id, :null => false
t.string :locale, :null => false, :limit => 2
@@ -36,24 +33,25 @@
class Author < ActiveRecord::Base
validates :name, :presence => true
end
-class TranslatableNews < ActiveRecord::Base
+class TranslatedNews < ActiveRecord::Base
validates :title, :content, :presence => true
validates :title, :uniqueness => true
- attr_accessible :title, :content
+ attr_accessible :title, :content, :locale, :origin_id
end
class News < ActiveRecord::Base
belongs_to :author
translatable do
- translatable :title
- translatable :content
- translatable_attr_accessible
+ field :title
+ field :content
end
+ accepts_nested_attributes_for :translations, :current_translation
+ attr_accessible :translations_attributes, :current_translation_attributes
attr_accessible :author_id, :author
end
\ No newline at end of file