when i try to create it says undefined method.
def create
@stock = Stock.find(params[:stock_availabilities][:stock_id])
@stock_availability = StockAvailability.new(stock_availabilities_params)
respond_to do |format|
if @stock_availability.save
format.html { redirect_to stock_path(v_id: @volunteer.id), notice: "stock saved successfully" }
else
@stock_availabilities = StockAvailability.where(stock_id: @stock.id).all
format.html { render 'index' }
end
end
end
Where stock_availabilities
belongs to Stock
table. foreign key
is stock_id
.
The params Generated in log is
Parameters: {
"utf8"=>"✓",
"authenticity_token"=>"ZWxRnGJqwLmhfosIhQ+xdLrG3HJXy1m/dHcizT+Y5+E=",
"stockavailability"=>{
"qty"=>"20",
"price"=>"2000",
"captured_at"=>"26/8/2015"
},
"commit"=>"Save Stockavailability"
}
Completed 404 Not Found in 1ms