title: ActiveModel::UnknownAttributeError (unknown attribute 'product_id' for Property.):
body: <p>So I am struggling with this error.  While building a react on rails project.</p>
  
  <blockquote>
    <p>Completed 500 Internal Server Error in 75ms (ActiveRecord: 6.1ms)
    ActiveModel::UnknownAttributeError (unknown attribute 'product_id' for >Property.):</p>
  </blockquote>
  
  <p>When I run this controller:</p>
  
  <pre><code>class SendDataController &lt; ApplicationController
      protect_from_forgery with: :null_session
  
      def save
          product = Product.create(name:params[:name], upc:params[:upc].to_i, available_on:params[:availableon])
  
          property = product.Properties.build(name:params[:properties][0][:name])
          property.save    
      end    
  end
  </code></pre>
  
  <p>I have tried to things found <a href="https://stackoverflow.com/questions/44752772/activemodelunknownattributeerror-unknown-attribute-creator-id-for-event">here</a> and <a href="https://stackoverflow.com/questions/48334075/activemodelunknownattributeerror-unknown-attribute-when-seeding-belongs-to-re">here</a>.  But I am getting no where.  Below is my current setup.  </p>
  
  <p>Models:</p>
  
  <pre><code>class ProductProperty &lt; ApplicationRecord
    belongs_to :Property
    belongs_to :Product
  end
  
  class Product &lt; ApplicationRecord
    has_many :Properties
    has_many :ProductProperties
  end
  
  class Property &lt; ApplicationRecord
    belongs_to :Product
    has_one :ProductProperty
  end
  </code></pre>
  
  <p>Migration:</p>
  
  <pre><code>class CreateProducts &lt; ActiveRecord::Migration[5.2]
    def change
      create_table :products do |t|
        t.string :name
        t.string :upc
        t.datetime :available_on
  
        t.timestamps
      end
    end
  end
  
  class CreateProperties &lt; ActiveRecord::Migration[5.2]
    def change
      create_table :properties do |t|
        t.string :name
  
        t.timestamps
      end
    end
  end
  
  class CreateProductProperties &lt; ActiveRecord::Migration[5.2]
    def change
      create_table :product_properties do |t|
        t.string :value
  
        t.timestamps
      end
    end
  end
  
  class AddProductRefToProperties &lt; ActiveRecord::Migration[5.2]
    def change
      add_reference :properties, :Product, foreign_key: true
    end
  end
  
  class AddProductRefToProductProperties &lt; ActiveRecord::Migration[5.2]
    def change
      add_reference :product_properties, :Product, foreign_key: true
    end
  end
  
  class AddPropertiesRefToProductProperties &lt; ActiveRecord::Migration[5.2]
    def change
      add_reference :product_properties, :Property, foreign_key: true
    end
  end
  </code></pre>
  
  <p>Schema:</p>
  
  <pre><code>ActiveRecord::Schema.define(version: 2018_09_24_163027) do
  
    create_table "product_properties", force: :cascade do |t|
      t.string "value"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.integer "Product_id"
      t.integer "Property_id"
      t.index ["Product_id"], name: "index_product_properties_on_Product_id"
      t.index ["Property_id"], name: "index_product_properties_on_Property_id"
    end
  
    create_table "products", force: :cascade do |t|
      t.string "name"
      t.string "upc"
      t.datetime "available_on"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
    end
  
    create_table "properties", force: :cascade do |t|
      t.string "name"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.integer "Product_id"
      t.index ["Product_id"], name: "index_properties_on_Product_id"
    end
  
  end
  </code></pre>
  
  <p>Thanks for any help you can give me!</p>