在rails中查看管理员
我有一个父表,子表,资金表。 家长登录,添加他的孩子,然后为每个孩子申请资助。
parent.rb
class Parent < ApplicationRecord has_many :children, dependent: :destroy has_many :secondaryparents, dependent: :destroy end
funding.rb
class Funding < ApplicationRecord has_many :organisations, dependent: :destroy belongs_to :child end
child.rb
class Child < ApplicationRecord belongs_to :parent has_many :fundings, dependent: :destroy end
Parent有一个字段作为管理员。 如果设置为true,则parent充当admin。 application.html.erb是admin的视图。 我能够将所有主要父母和他们的孩子展示在彼此面前。 我需要帮助,在他们面前展示孩子们的资助申请。
application.html.erb
Application Status
Primary Parent Name <!-- Financial Status --> Child Name Activity Organisation Activity Start Date Date Submitted Amount Requested Funds Available Status
财务状况,活动,活动开始日期,提交日期,申请金额,可用资金都是资金表的所有领域。 资助表有child_id。 子表有parent_id。 请帮助
更新
你可以做child.fundings.each do | funding | 然后做所有的资金属性。