Permalink
Browse files

fix remove unsubscribe number and voice number bug

  • Loading branch information...
1 parent 2fe90a6 commit 423cfe4e8305093ff3430d10c8e318ce06b5eec3 Willa committed Nov 13, 2012
Showing with 13 additions and 7 deletions.
  1. +10 −5 lib/crowdring/crowdring.rb
  2. +1 −1 lib/views/unsubscribe_number.haml
  3. +2 −1 lib/views/voice_numbers.haml
View
@@ -136,8 +136,8 @@ def process_request(service_name, request, response_type)
end
end
- post '/unsubscribe_numbers/:phone_number/destroy' do
- unsubscribe_number = AssignedUnsubscribeVoiceNumber.get(params[:phone_number])
+ post '/unsubscribe_numbers/:id/:phone_number/destroy' do
+ unsubscribe_number = AssignedUnsubscribeVoiceNumber.get(params[:id], params[:phone_number])
if unsubscribe_number.destroy
flash[:notice] = "Unsubscribe number removed"
else
@@ -305,9 +305,14 @@ def process_request(service_name, request, response_type)
post '/campaign/:id/assigned_voice_number/destroy' do
campaign = Campaign.get(params[:id])
- campaign.voice_numbers.get(params[:voice_number]).destroy
- flash[:notice] = "Voice number has been removed"
- redirect to("/campaigns##{campaign.id}")
+ unless campaign.voice_numbers.count == 1
+ campaign.voice_numbers.get(params[:voice_number]).destroy
+ flash[:notice] = "Voice number has been removed"
+ redirect to("/campaigns##{campaign.id}")
+ else
+ flash[:errors] = "Must have at least one voice number"
+ redirect to("/campaigns##{campaign.id}")
+ end
end
post '/tags/create' do
@@ -1,4 +1,4 @@
%h4 #{number.pretty_phone_number}
-%form{action: "/unsubscribe_numbers/#{number.phone_number}/destroy", method: 'post'}
+%form{action: "/unsubscribe_numbers/#{number.id}/#{number.phone_number}/destroy", method: 'post'}
%button{type: 'submit'} Remove
@@ -7,5 +7,6 @@
-voice_numbers.each do |voice_number|
%h4= "Phone Number: #{voice_number.pretty_phone_number}, Description: #{voice_number.description}"
%form{action: "/campaign/#{campaign.id}/assigned_voice_number/destroy", method: 'post'}
- %input{type: 'hidden', name: 'voice_number', value: "#{voice_number.phone_number}"}
+ %input{type: 'hidden', name: 'phone_nubmer', value: "#{voice_number.phone_number}"}
+ %input{type: 'hidden', name: 'voice_number[id]', value: "#{voice_number.id}"}
%button{type: 'submit'} Remove

0 comments on commit 423cfe4

Please sign in to comment.