Skip to content

Instantly share code, notes, and snippets.

@doug7410
Created December 12, 2014 16:43
Show Gist options
  • Save doug7410/7997f41a0326d4b3bd9a to your computer and use it in GitHub Desktop.
Save doug7410/7997f41a0326d4b3bd9a to your computer and use it in GitHub Desktop.
create action for sending a notification
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