ruby on rails - Nested form fields not showing in polymorphic association -


hi have polymorphic association document model storing document uploads. i'm trying submit document attributes nested attribute via associated model.

however, when load form, nested field not show. missing?

schema:

  create_table "documents", force: :cascade |t|     t.json     "links"     t.integer  "linkable_id"     t.string   "linkable_type"     t.datetime "created_at"     t.datetime "updated_at"   end    add_index "documents", ["linkable_type", "linkable_id"], name: "index_documents_on_linkable_type_and_linkable_id", using: :btree 

models:

class document < activerecord::base   belongs_to :linkable, polymorphic: true   belongs_to :user   belongs_to :company    mount_uploaders :links, docuploader end    class customerplan < activerecord::base   has_many :documents, as: :linkable   accepts_nested_attributes_for :documents end 

controller:

class customerplancontroller < applicationcontroller    def new     @customer_plan = current_company.customer_plans.build   end    def create     @customer_plan = current_company.customer_plans.build(customer_plan_params)      if @customer_plan.save       redirect_to @customer_plan, notice: 'customer plan created.'     else       render :new     end   end    private     def cusomter_plan_params       params.require(:cusomter_plan_params).permit(:date, :name, :plan_type,          documents_attributes: [:id, links: []])     end end 

form:

<%= simple_nested_form_for @stock_plan, :html => { :multipart => true } |f| %>   <%= f.error_notification %>      <%= f.input :date %>     <%= f.input :name %>     <%= f.input :plan_type %>      <%= f.simple_fields_for :documents |d| %>       <p><b>upload here:</b></p>       <%= d.file_field :links, multiple: true %>       <br>     <% end %>     <%= f.button :submit%> <% end %> 


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -