簡體   English   中英

活動管理員-has_and_belongs_to_many關系

[英]Active Admin - has_and_belongs_to_many relationships

的Gemfile

gem 'rails', '4.1.7'
gem 'activeadmin', github: 'activeadmin'

健康狀況

型號:HealthProfile

has_and_belongs_to_many :health_concerns, :join_table => :health_profile_health_concerns

表名稱:health_profiles

health_profiles
id
name

健康狀況健康問題

模型HealthProfileHealthConcern

表名稱= health_profile_health_concerns

health_profile_health_concerns
health_profile_id
health_concerns_id

健康問題

健康關注模型

has_and_belongs_to_many :health_profiles, :join_table => :health_profile_health_concerns

表名稱= health_concerns

health_concerns
id
name

我的目標是訪問選定的health_profile的health_concerns。

我應該創建這樣的鏈接嗎? 但是對於這個例子(血壓),我使用了與has_and_belongs_to_many不同的多對多關系

li link_to "Blood Pressure",    admin_health_profile_blood_pressures_path(health_profile)

我會使用has_many througth關聯。

在Active Admin中has_and_belongs_to_many可能花費很少的時間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM