我有一个注册应用程序,它记录一个Participant模型,其中有两个悬挂模型 -Student_Detail和Volunteer_Detail. Participant has_one的Student_Detail和Volunteer_Detail。
还有第三种模式,Group. Group记录哪些参与者相互匹配。由于参与者可能涉及一个以上的Group和Group可能有不止一个Participant,我认为has_and_belongs_to_many是最佳组合Participant和Group。
一个连接表存在于Group和Participant
我是 Rails 的新手,我正在使用活动管理员来管理这个应用程序。
当我登录时,我可以看到我作为资源生成的每个模型,但我希望能够在查看Participant选项卡时显示每个参与者的相关详细信息(学生/志愿者/组)。目前,它仅显示仅适用于该特定模型的属性,而不显示任何关联模型的属性。
这是我的模型的 active_admin 资源代码Participant:
ActiveAdmin.register Participant do
permit_params :first_name, :last_name, :gender, :email, :birthdate, :phone,
:street_name, :city, :state, :zip, :role, student_details_attributes: [:nationality, :religion, :need_ride,
:has_spouse, :spouse_name, :english_level, :expectation, :length_of_stay, :exact_length, :volunteer_id,
:matched, :returned_home, :participant_id], volunteer_details_attributes: [:date, :importance, :story, …Run Code Online (Sandbox Code Playgroud) ruby-on-rails has-and-belongs-to-many activeadmin rails-activerecord