Note that there are some explanatory texts on larger screens.

plurals
  1. POEdit form load error using Formtastic, STI, Polymorphic & ActiveAdmin
    text
    copied!<p>I am new to rails and using a combination of formtastic, activeadmin,sti and polymorphic associations to build a form</p> <p>When I I can create a nested form with the address parent with no problem, but when i introduce STI and attempt to build_origin_address instead of build_address, that is when I get the error below when loading the edit view </p> <p>NameError in Admin/leads#edit Showing .../app/views/admin/leads/_form.erb where line #3 raised: uninitialized constant Lead::OriginAddress</p> <p>Models:</p> <pre><code>class Address &lt; ActiveRecord::Base belongs_to :addressable, :polymorphic =&gt; true belongs_to :lead validates :line1, :presence =&gt; true, :length =&gt; {:minimum =&gt; 2} attr_accessible :line1, :line2, :city, :state, :zip, :country end class OriginAddress &lt; Address end class DestinationAddress &lt; Address end class Lead &lt; ActiveRecord::Base has_one :origin_address, :dependent =&gt; :destroy, :as =&gt; :addressable accepts_nested_attributes_for :origin_address, :allow_destroy =&gt; true end </code></pre> <p>partial used in edit view:</p> <pre><code>&lt;%= semantic_form_for [:admin, @lead] do |f| %&gt; &lt;% @lead.build_origin_address unless @lead.origin_address %&gt; &lt;%= f.inputs :name =&gt; "Lead Info" do %&gt; &lt;%= f.input :first_name %&gt; &lt;%= f.input :last_name %&gt; &lt;% end %&gt; &lt;%= f.semantic_fields_for :origin_address do |origin| %&gt; &lt;%= origin.inputs :name =&gt; "Origin Address" do %&gt; &lt;%= origin.input :line1 %&gt; .... &lt;% end %&gt; &lt;% end %&gt; &lt;%= f.buttons do %&gt; &lt;%= f.commit_button %&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload