RJS & increment variable - this is an interesting one

I use the same idea for enabling users to add infinite number of attachments and other things. However, I don't use a variable and increment, instead I use the time as follows:

partial: <% index = Time.now.tv_sec %> <input id="attachment_data" name="attachment[<%=index%>][data]" size="30" type="file" />

Hi Mike,

when the action "add_new" of controller "Goals" is called, a new instance of Goals controller is created and hence previous value of @task is no more accessible in add_new. Hence when you have something like this "@task = @task.succ " in your add_new method, it will give error, since @task is not defined and you are trying to invoke nil.succ.

You need to persist @task across requests, 1 way is to use sessions. Another approach could be the one mentioned by Ahmed.

Regards Jatinder