i am trying to declare a dynamic array like below.
<% Product_in_Stock_array = [] %>
but it is not working giving syntax error.
You have to be a bit more specific.
The code you have is most likely an erb template file.
This is actually a valid erb template
ERB.new('<% Product_in_Stock_array = [] %>').result
Your syntax error has to be somewhere else.
Additionally you most likely want to create a variable not a constant. In Ruby names starting with capital letter are constants (written in UpperCamelCase or UPPER_CASE most often), normal variables are written in camel_case.
Array, constant which is the empty array. For experimenting with the syntax, don't do it in templates, but do it first insideirb. Constants are nor really constant in Ruby, but you get an error message if you try to reassign it.