问题
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>
回答1:
Either rename or overwrite as the errors says overwrite via something like
set_inheritance_column "not_sti"
source: http://my.safaribooksonline.com/book/web-development/ruby/9780132480345/advanced-active-record/ch09lev1sec5
来源:https://stackoverflow.com/questions/11000703/cant-figure-out-activerecordsubclassnotfound-in-registriesedit