Q: How to send params from nested forms? I'm making a POST request from a nested form which is written in reactjs such that it is making an ajax request to create method of the products controller. 
React Code:
I have an empty object in the getInitialState like this
getInitialState: function() {
 return {
   products: [{name: '', price: '', quantity: ''}],
   count: 1
 };
},

When i submit the form,
handleSubmit: function(e) {
  e.preventDefault();
  var productsArray = this.state.products;
  $.ajax({
    data: {
      product: productsArray
    },
    url: '',
    type: "POST",
    dataType: "json",
    success: function ( data ) {
      console.log(data);
      // this.setState({ comments: data });
    }.bind(this)
  });
},

the object gets populated and the parameter hash becomes like this 
Parameters: {"product"=>{"0"=>{"name"=>"", "price"=>"", "quantity"=>""}}, "shop_id"=>"gulshop"}

So i'm getting 
ActiveRecord::UnknownAttributeError (unknown attribute '0' for Product.):

How can i get the parameter hash like this:
Parameters: {"product"=>[{"name"=>"", "price"=>"", "quantity"=>""}], "shop_id"=>"gulshop"}

What can be done for it ?

A: Your original error 'unknown attribute '0' for Product.' is because the Product class does not have an attribute '0'. I'm not sure where the '0' is coming from as you haven't posted your react code that makes the request.
You can easily make a request from your component using jQuery's .ajax method. e.g
$.ajax({
  type: 'POST',
  url: '/your_url',
  data: {
    course: {
      name: 'Hello World',
      price: 120
    }
  }
});

You would then have something like the following in your controller..
class ProductController < ApplicationController
  def create
    @product = Product.create(product_params)
  end

  private

  def product_params
    params.require(:product).permit(:name, :price)
  end
end

