Hi,
I am quite new to RoR, and now I am working on a muliple file-upload
page. I want to make one very similar to the one in Gmail.
Here is the code I wrote:
In the controller:
session[:upload_count] = 0 if request.get?
def attach
session[:upload_count] += 1
render :layout => false
end
def remove
render :nothing => true
end
In the view:
#compose.rhtml
<div id=''upload''>
<%= link_to_remote ''Attach image'', :update =>
''upload'', :url =>
{:action => ''attach''}, :position =>
''before'' %>
</div>
#attach.rhtml
<div id=<%= "image#{session[:upload_count]}" %>>
<%= file_column_field "image[#{session[:upload_count]}]",
"image" %>
<%= link_to_remote ''remove'', :update =>
"image#{session[:upload_count]}", :url => {:action =>
''remove''} %><br />
</div>
Here is the problem, the attach function works fine, but when the remove
function is called, it only removes the last file field instead of the
proper one. I guess that''s because the link_to_remote tag gets
parameters dynamically here. So is there any way to solve this? Do I
have to use rjs?
One more question, I believe there is some better way other than using
session to store the upload_count variable, but I cannot find one, could
anyone give me a hint?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---