Created
December 12, 2014 16:43
-
-
Save doug7410/7997f41a0326d4b3bd9a to your computer and use it in GitHub Desktop.
create action for sending a notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
if the_customer_is_missing | |
@notification.errors[:base] << "Please choose a customer or add a new one." | |
render :index | |
elsif a_new_customer_is_being_added | |
if @customer.valid? | |
send_text_if_notification_and_customer_valid! | |
else | |
@notification.errors.clear | |
render :index | |
end | |
elsif sending_to_an_existing_customer | |
if @notification.valid? | |
handle_sending_text_message(notification: @notification) | |
else | |
render :index | |
end | |
else | |
flash[:error] = "There was a problem. The notification could not be sent." | |
render :index | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment