私は obj @files を持っています。これには 1 セットのデータ (1 つのファイル) が含まれることもあれば、多くのファイルが含まれることもあります。
私は create.js.erb を持っています。これが現在私がしていることです。
<% if @files.new_record? %>
alert("Failed to upload: <%= j @files.errors.full_messages.join(', ').html_safe %>");
<% else %>
$(".container").append('<div id="cfile"><%= j render(@files) %></div>');
<% end %>
それから私は _file.html.erb と呼ばれるパーシャルを持っています
<%= file.name %>
<%= file_.id %>
これはすべて正常に機能しますが、さまざまな種類のファイルのパーシャルを作成しようとすると問題が発生します。
みたいなことができるようになりたい
if file.first.type == image # (Even If the come in groups they would be the same type so i just need one .type field from one of them.)
$(".different_container").append(render different partial here);
else if file.first.type == doc
$(".another_container").append(render another partial here);
これについてどうすればいいですか?何かを明確に説明していない場合は質問してください。