想不通的ActiveRecord :: SubclassNotFound在注册#编辑? [英] Can't figure out ActiveRecord::SubclassNotFound in Registries#edit?
问题描述
当在编辑或表演这来了:
的ActiveRecord :: SubclassNotFound在注册#修改
的单表继承机制未能找到该子类:'飞机'引发此错误的原因列'类型'被保留用于存储类的情况下继承请,如果你没有重命名此列打算将它用于存储继承类或覆盖present.inheritance_column使用另一列提供的信息。
25:< / DIV>
26:
27:< DIV CLASS =字段1>
28:<%= f.fields_for:presents办|制造商| %>
29:<%=渲染'present_fields',F:建设者%>
30:<%结束%GT;
31:< / DIV>
下面的登记表:
<%= nested_form_for(@registry)办| F | %>
<%@如果registry.errors.any? %>
< DIV ID =error_explanation>
< H2><%=复数(@ registry.errors.count,错误)%>禁止此注册表从
被保存:< / H>
< UL>
<%@ registry.errors.full_messages.each办|味精| %>
<李><%=味精%>< /李>
<%结束%GT;
< / UL>
< / DIV>
<%结束%GT;
<%= f.label:DUE_DATE%>< BR />
<%= f.date_select:DUE_DATE,:行数=> 5%GT;
<%= f.label:主题%>< BR />
<%= f.text_field:主题:类=> FIELD2%>
< DIV CLASS =字段1>
<%= f.label:性别%>< BR />
<%= f.text_field:性别%>
< / DIV>
< DIV CLASS =字段1>
<%= f.fields_for:presents办|制造商| %>
<%=渲染'present_fields',F:建设者%>
<%结束%GT;
< / DIV>
<%= link_to_add_fields添加presents,F:presents%GT;
< DIV CLASS =行动>
&其中;%= f.submit%GT;
< / DIV>
<%结束%GT;
在presents_fields:
< DIV CLASS =字段1>
<表>
&其中; TR>
< TD> <%= f.label:类型,present键入%> < / TD>
< TD> <%= f.text_field:类型:类=> FIELD2%> < / TD>
< TD> <%= f.label:数量,数量%GT; < / TD>
< TD> <%= f.number_field:数量:类=> FIELD3%> < / TD>
< TD> <%= f.label:颜色,颜色%> < / TD>
< TD> <%= f.text_field:色泽:类=> FIELD2%> < / TD>
< TD> <%= f.label:品牌,品牌%GT; < / TD>
< TD> <%= f.text_field:品牌:类=> FIELD2%> < / TD>
< TD> <%= f.link_to_remove删除此present%>< / TD>
< / TR>
< /表>
< / DIV>
无论是重命名或覆盖的错误说: 通过类似
覆盖 set_inheritance_columnnot_sti
来源: <一href="http://my.safaribooksonline.com/book/web-development/ruby/9780132480345/advanced-active-record/ch09lev1sec5" rel="nofollow">http://my.safaribooksonline.com/book/web-development/ruby/9780132480345/advanced-active-record/ch09lev1sec5
When in "edit" or "show" this comes up:
ActiveRecord::SubclassNotFound in Registries#edit
"The single-table inheritance mechanism failed to locate the subclass: 'Plane'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Present.inheritance_column to use another column for that information."
25: </div>
26:
27: <div class="field1">
28: <%= f.fields_for :presents do |builder| %>
29: <%= render 'present_fields', f: builder %>
30: <% end %>
31: </div>
Here is the Registry Form:
<%= 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 %>
The 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>
Either rename or overwrite as the errors says overwrite via something like
set_inheritance_column "not_sti"
这篇关于想不通的ActiveRecord :: SubclassNotFound在注册#编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!