Guest User

Untitled

a guest
Jan 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <div class="simple_form-field">
  2. <% if !@product.valid? && !@product.id || @product.photo_errors? || !@product.photo.file? %>
  3. <%= f.file_field(:photo) %>
  4. <% [:photo_file_size, :photo_file_name, :photo_content_type].each do |attr| %>
  5. <% if !@product.errors[attr].blank? %>
  6. <div class="field_error"><%= @product.errors[attr][0] %></div>
  7. <% end %>
  8. <% end %>
  9. <% else %>
  10. <div class="simple_form-field-photo">
  11. <p class="hidden"><%= f.file_field :photo, :id => 'product_image' %></p>
  12. <p id="product_image_text">
  13. <%= image_tag(@product.photo.url(:medium), :alt => @product.name) %><br>
  14. </p>
  15. <p><%= link_to_function("Change", "add_field('product_image', '', 'Cancel changes', this)") %></p>
  16. </div>
  17. <% end %>
  18. </div>
Add Comment
Please, Sign In to add comment