Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Delete button on form

  • Loading branch information...
commit 4951d50a4788ae86b2ef584a48345de22a6fe3c0 1 parent cc7f1e0
Bob authored
View
13 app/views/user_profiles/_form.html.erb
@@ -16,10 +16,15 @@
<% elsif entry.display_type == "upload_pic" %>
- page.insert_html :bottom, :user_profile_pics, :partial => 'user_profile_pic', :object => UserProfilePics.new
- <%#= send("text_field", *args) %>
- <%= render :partial => "user_profile_pic", :object => UserProfilePics.new >
-
+
+ <div class="photo">
+ <% fields_for "user_profile[user_profile_pic_attributes][]", user_profile_pic do |p| %>
+ <p>
+ <%= p.file_field :photo, :index => nil %>
+ <%= link_to_function "delete", "remove_field($(this), ('user_profile_pic'))" %>
+ </p>
+ <% end %>
+ </div>
View
4 app/views/user_profiles/_user_profile_entries.html.erb
@@ -10,6 +10,10 @@
<div class='pic_box'>
<%= image_tag(entry.content, {:alt => @user_profile.user.proper_name, :class => "profile_pic"}) %>
</div>
+ <% unless entry.content.nil? && entry.display_type != "upload_pic" %>
+ <div class='pic_box'>
+ <%= image_tag(entry.user_profile_pics.photo.url(:thumb)) %>
+ </div>
<% else %>
<strong><%=h "#{entry.field_name}: " %></strong>
<%=h entry.content %>
View
1  config/environment.rb
@@ -57,6 +57,7 @@
config.gem 'ar_mailer', :lib => 'action_mailer/ar_mailer'
config.gem "javan-whenever", :lib => false, :source => "http://gems.github.com"
config.gem "ar-extensions"
+ config.gem "paperclip"
#make sure you remove 'ar_mailer' - sudo gem uninstall ar_mailer - this is an old version
# Only load the plugins named here, in the order given. By default, all plugins
View
4 public/javascripts/application.js
@@ -1,2 +1,6 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
+
+function remove_field(element, item) {
+ element.up(item).remove();
+}
Please sign in to comment.
Something went wrong with that request. Please try again.