我想在我的Rails應用程序中擁有乾淨整潔的結構。Rails 3 - 模型結構
現在我在模型文件夾中有4個文件:Post,PostTranslation,PostCategory和PostCategoryTranslation。
這是我post.rb
class Post < ActiveRecord::Base
attr_accessible :image, :image_cache, :remove_image, :post_category_ids, :post_categories_attributes, :post_translations_attributes
validates :post_translations, :post_categories, presence: :true
translates :name, :content
has_many :post_translations, dependent: :destroy
accepts_nested_attributes_for :post_translations, allow_destroy: true
end
這是post_translation.rb
class PostTranslation < ActiveRecord::Base
attr_accessible :locale, :name, :content
validates :name, length: { maximum: 255 }, presence: true
validates :content, :locale, presence: true
belongs_to :post
end
我該怎麼辦?最佳做法是什麼?創建發佈文件夾並將翻譯移動到此文件夾中並創建子模型?就像這樣:class Translation < Post
謝謝你的建議