当出现“编辑”或“显示”时,会出现:
注册表中的ActiveRecord :: SubclassNotFound#edit
“单表继承机制无法找到子类:'Plane'。引发此错误是因为列'type'保留用于存储继承的类。如果不是,请重命名此列打算将它用于存储继承类或覆盖Present.inheritance_column以使用另一列来获取该信息。“
25: </div>
26:
27: <div class="field1">
28: <%= f.fields_for :presents do |builder| %>
29: <%= render 'present_fields', f: builder %>
30: <% end %>
31: </div>
这是注册表:
<%= nested_form_for(@registry) do |f| %>
<% if @registry.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@registry.errors.count, "error") %> prohibited this registry from
being saved:</h2>
<ul>
<% @registry.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.label :due_date %><br />
<%= f.date_select :due_date, :rows => 5 %>
<%= f.label :theme %><br />
<%= f.text_field :theme, :class => 'field2' %>
<div class="field1">
<%= f.label :gender %><br />
<%= f.text_field :gender %>
</div>
<div class="field1">
<%= f.fields_for :presents do |builder| %>
<%= render 'present_fields', f: builder %>
<% end %>
</div>
<%= link_to_add_fields "Add Presents", f, :presents %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
presents_fields:
<div class="field1">
<table>
<tr>
<td> <%= f.label :type, "Present Type" %> </td>
<td> <%= f.text_field :type, :class => 'field2' %> </td>
<td> <%= f.label :Quantity, "Quantity" %> </td>
<td> <%= f.number_field :quantity, :class => 'field3' %> </td>
<td> <%= f.label :color, "Color" %> </td>
<td> <%= f.text_field :color, :class => 'field2' %> </td>
<td> <%= f.label :brand, "Brand" %> </td>
<td> <%= f.text_field :brand, :class => 'field2' %> </td>
<td> <%= f.link_to_remove "Remove this present" %></td>
</tr>
</table>
</div>
答案 0 :(得分:3)
如错误所示重命名或覆盖 通过
之类的东西覆盖set_inheritance_column "not_sti"