Skip to content

Commit

Permalink
Fixing delete bug that ben found
Browse files Browse the repository at this point in the history
  • Loading branch information
bidsync committed Sep 15, 2009
1 parent b6a427b commit fc5c659
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/models/developer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions app/routes/departments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions app/routes/developers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/views/departments/show.haml
Original file line number Diff line number Diff line change
@@ -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})"

Expand Down
2 changes: 1 addition & 1 deletion app/views/developers/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/developers/show.haml
Original file line number Diff line number Diff line change
@@ -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)})"

Expand Down
2 changes: 1 addition & 1 deletion app/views/partials/delete_form_button.haml
Original file line number Diff line number Diff line change
@@ -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.