I have a ProductPrice, Product and Menu

Product belongs\_to Menu and ProductPrice to Product.

I'm creating the Product with prices in one time through cocoon nested objects.

In ProductPrice I have this code:

```
def menu
  self.product.menu;
end

```

The price depends on the product\_category and the sizes. So when creating a new product, the user selects the category it belongs to and then through ajax the product\_prices are fetched so the user can fill in a price for each size of that product. Prices are fetched with this procedure:

```
def self.get_product_prices(category_id, product_id)
  if category_id != "0"
    MenuCategory.find(category_id).product_sizes.map do |size|
      if product_id == "0"
        ProductPrice.new({:product_size_id => size.id })
      else
        ProductPrice.find_or_initialize_by_product_size_id_and_product_id(size.id, product_id)
      end
    end
  end
end

```

On creating this gives me an error since product is returned as nil. Is there any way to get the menu the non-persisted product belongs to? I can see it ProductPrice has a filled in product\_id attribute and Product is always created with a filled in menu\_id.