0
我已經在表繼承時尚中設置了一些模型,一切似乎都很好,並且很棒。但是,當我使用集合選擇字段從其中一個模型中選擇值時,它會保存它,但它保存了數據的ID而不是數據的實際值。所以當我嘗試在show view上顯示值時,它只顯示相應的ID而不是實際值。Rails表繼承問題
這是我的設置。我使用formtastic作爲附註。
查看
<%= show_field "County", @company.county %>
表
<%= f.input :county, :label => 'County', :as => :select, :collection => County.find(:all) %>
基本型號
class Tag < ActiveRecord::Base
before_create :set_type
before_update :set_type
attr_accessible :type, :name, :category
belongs_to :company
def set_type
self.type = self.category
end
end
繼承的模型
class County < Tag
end