如何在Rails中實現這種結構?如何添加關聯到模塊?
User
has_one :health
Health
belongs_to :user
has_many :weights
has_many :diseases
Health::Weight
belongs_to :health
Health::Diseases
belongs_to :health
users
health_id:integer
healths
id:integer
health_weights
current:integer
health_id:integer
health_diseases
name:text
health_id:integer
當我產生r g model Health::Weight current:integer
我Health
是沒有ActiveRecord的模塊:
module Health
def self.table_name_prefix
'health_'
end
end
我這個好辦法?
所以,這裏有什麼問題嗎? –
我更新了問題。 – tomekfranek