Created
August 1, 2012 17:18
-
-
Save bhoggard/3228946 to your computer and use it in GitHub Desktop.
partial for adding additional images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class='image'> | |
<% new_or_existing = image.new_record? ? 'new' : 'existing' %> | |
<% prefix = "work[#{new_or_existing}_image_attributes][]"%> | |
<% fields_for prefix, image do |f| %> | |
<p> | |
<%= f.label :caption %><br /> | |
<%= f.text_field :caption %> | |
</p> | |
<p> | |
<% if new_or_existing == 'existing' %> | |
<%= image_tag(image.file.url(:thumb, false)) %><br /><br /> | |
Replace: <%= f.file_field :file %> | |
<%= link_to_function "remove", "$(this).parent().parent().remove()"%> | |
<% else %> | |
File: <%= f.file_field :file %> | |
<%= link_to_function "remove", "$(this).parent().parent().remove()"%> | |
<% end %> | |
<hr style="width: 50%" /> | |
</p> | |
<% end -%> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment