Rails - 不显示嵌套属性视图

Rails - Nested attributes views are not shown

我正在使用连接 table 和嵌套属性在单独的 table 投资者资料中收集投资者兴趣列表。由于某些原因,我的视图是空的,没有显示要更新的 investor_interest 文本字段。你能找到原因吗?我的代码如下。

investor_profile.rb

class InvestorProfile < ApplicationRecord
  belongs_to :user

  has_many :investor_profile_interests
  has_many :investor_interests, through: :investor_profile_interests

  accepts_nested_attributes_for :investor_profile_interests

end

investor_interest.rb

class InvestorInterest < ApplicationRecord
  has_many :investor_profile_interests
  has_many :investor_profiles, through: :investor_profile_interests
end

investor_profile_interest.rb

class InvestorProfileInterest < ApplicationRecord
  belongs_to :investor_profile
  belongs_to :investor_interest

end

投资者档案管理员

def new
  @investor_profile = InvestorProfile.new
end

观看次数

<%= form_with model: @investor_profile, class: 'form new-profile-form' do |f| %>
   <div class="field">
      <%= f.fields_for :investor_profile_interests do |test| %>
        <%= test.text_field :investor_interest %>
      <% end %>
   </div>
  <div class="field">
      <%= f.submit 'Submit', class: 'button is-primary is-normal' %>
   </div>
<% end %>

在新方法中,构建 investor_profile_interests -

def new
  @investor_profile = InvestorProfile.new
  @investor_profile.investor_profile_interests.build
end