From 77b8fcdd1d78461baa541f8fd95962a544deef90 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Fri, 9 Sep 2011 13:44:43 +0800 Subject: [PATCH] Fix previous workaround for the uploaded Design --- app/models/design/design.rb | 12 ++++++++---- app/views/admin/designs/_design_file.html.erb | 2 +- app/views/admin/designs/_form.html.erb | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/models/design/design.rb b/app/models/design/design.rb index 9346c175..1d4a5284 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -86,10 +86,14 @@ class Design def process_object(object) if object.to_save - new_object = self.send(object._type.downcase.pluralize).build - new_object.file = object.file - object.destroy - new_object.save + if object.file_filename.nil? + new_object = self.send(object._type.downcase.pluralize).build + new_object.file = object.file + object.destroy + new_object.save + else + object.save + end end if object.to_destroy object.destroy diff --git a/app/views/admin/designs/_design_file.html.erb b/app/views/admin/designs/_design_file.html.erb index 3fbb9ab4..205b5350 100644 --- a/app/views/admin/designs/_design_file.html.erb +++ b/app/views/admin/designs/_design_file.html.erb @@ -11,7 +11,7 @@ <% end %> <%= t('Delete') %> <% end %> - <% if classes.include?('r_editable') %> + <% if classes.include?('r_edit') %> <%= t('Edit') %> <% end %> diff --git a/app/views/admin/designs/_form.html.erb b/app/views/admin/designs/_form.html.erb index 8095e9fd..9a857f43 100644 --- a/app/views/admin/designs/_form.html.erb +++ b/app/views/admin/designs/_form.html.erb @@ -36,11 +36,11 @@ <% end %>

- <%= render :partial => 'design_file', :locals => { :object => @design, :field_name => "themes", :f => f, :classes => "r_destroy, r_editable" } %> + <%= render :partial => 'design_file', :locals => { :object => @design, :field_name => "themes", :f => f, :classes => "r_destroy, r_edit" } %>

- <%= render :partial => 'design_file', :locals => { :object => @design, :field_name => "javascripts", :f => f, :classes => "r_destroy, r_editable" } %> + <%= render :partial => 'design_file', :locals => { :object => @design, :field_name => "javascripts", :f => f, :classes => "r_destroy, r_edit" } %>