【问题标题】:Active Admin - has_and_belongs_to_many relationships活动管理员 - has_and_belongs_to_many 关系
【发布时间】:2015-02-18 10:20:10
【问题描述】:

宝石文件

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

健康状况

模型:健康档案

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)

【问题讨论】:

    标签: ruby-on-rails ruby activeadmin


    【解决方案1】:

    我会使用 has_many througth 关联。

    has_and_belongs_to_many可以在 Active Admin 中花费很少的问题。

    【讨论】:

    • 这没有回答 OPs 的问题,也没有提供任何明确的理由不这样做。更多细节可能对社区有价值。
    • 对不起,你错了。这个答案是一个建议。过去,我在 github 问题页面上从 activeadmin 和 formtastic 那里得到了相同的答案。因此,它来自个人经验,如果了解您可以使用相同的 github 问题跟踪器作为解决问题的第一个来源,则不需要明确的推理。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-27
    • 2012-03-23
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    相关资源
    最近更新 更多