Permalink
Browse files

Fixing delete bug that ben found

  • Loading branch information...
1 parent b6a427b commit fc5c659ea2bd89e7fde8a69d2e4ca9f35dae618a @bidsync bidsync committed Sep 15, 2009
View
@@ -10,7 +10,11 @@ class Developer < ActiveRecord::Base
validates_presence_of :name, :email
def first_name
- name.split(" ").first
+ if name =~ /\s+/
+ name.split(" ").first
+ else
+ name
+ end
end
end
@@ -70,6 +70,8 @@ class Main
else
name = @department.name
@department.delete
+ @projects = ProjectMeta.find_all_by_department_id params[:department_id]
+ @projects.each {|project| project.department_id = nil; project.save} unless @projects.nil? || @projects.empty?
add_message "Successfully deleted department #{name}"
end
redirect "/departments"
View
@@ -69,6 +69,8 @@ class Main
else
name = @developer.name
@developer.delete
+ @projects = ProjectMeta.find_all_by_developer_id params[:developer_id]
+ @projects.each {|project| project.developer_id = nil; project.save} unless @projects.nil? || @projects.empty?
add_message "Successfully deleted developer #{name}"
end
redirect "/developers"
@@ -1,7 +1,7 @@
.context-nav.right
%a{:href => "/department/#{@department.id}/edit", :title => "Edit #{@department.name}"} Edit
or
- != partial :"partials/delete_form_button", :action => "/department/#{@department.id}/delete", :id => @department.id
+ != partial :"partials/delete_form_button", :action => "/department/#{@department.id}", :id => @department.id
.page-title!= "#{@department.name} (#{@department.contact})"
@@ -17,7 +17,7 @@
%td
%a{:href => "/developer/#{developer.id}/edit", :title => "Edit #{developer.name}"} Edit
or
- != partial :"partials/delete_form_button", :action => "/developer/#{developer.id}/delete", :id => developer.id
+ != partial :"partials/delete_form_button", :action => "/developer/#{developer.id}", :id => developer.id
- else
No developers found here
@@ -1,7 +1,7 @@
.context-nav.right
%a{:href => "/developer/#{@developer.id}/edit", :title => "Edit #{@developer.name}"} Edit
or
- != partial :"partials/delete_form_button", :action => "/developer/#{@developer.id}/delete", :id => @developer.id
+ != partial :"partials/delete_form_button", :action => "/developer/#{@developer.id}", :id => @developer.id
.page-title!= "#{@developer.name} (#{show_email(@developer)})"
@@ -1,3 +1,3 @@
-%form{:method => "post", :name => "delete_form_button_#{id}", :action => action, :class => "inline-button", :onsubmit => "return confirm(\"Are you sure you would like to delete this item?\");"}
+%form{:method => "post", :name => "delete_form_button_#{id}", :action => action, :class => "inline-button", :onsubmit => "return confirm(\"Warning: Deleting this item will clear all associations to active projects.\\nAre you sure you would like to delete this item?\");"}
%input{:type => "hidden", :name => "_method", :value => "delete"}
%input{:type => "submit", :value => "Delete"}

0 comments on commit fc5c659

Please sign in to comment.