Ruby 带有引导导航选项卡的rails视图
我有两个模型。父母和孩子。每个父母都有许多孩子Ruby 带有引导导航选项卡的rails视图,ruby,bootstrap-4,ruby-on-rails-5,Ruby,Bootstrap 4,Ruby On Rails 5,我有两个模型。父母和孩子。每个父母都有许多孩子 #parent model class Parent < ApplicationRecord has_many :children end #child model class Child < ApplicationRecord belongs_to :parent end 父模型 类父类
#parent model
class Parent < ApplicationRecord
has_many :children
end
#child model
class Child < ApplicationRecord
belongs_to :parent
end
父模型
类父类<应用程序记录
你有很多孩子吗
结束
#子模型
类子类<应用程序记录
属于:父
结束
我想使用引导导航选项卡
,每个选项卡应仅显示家长的子女。任何帮助
parent
table=children.parent.id
- 在
ParentController
返回父项具有子项的唯一名称@parent\u children
@parent_children = Parent.select('DISTINCT name').joins(:children).where('id' = 'children.parent.id')