Skip to content

Instantly share code, notes, and snippets.

@RubyRonin
Last active August 29, 2015 14:13
Show Gist options
  • Save RubyRonin/3fbb86134f4d045b677f to your computer and use it in GitHub Desktop.
Save RubyRonin/3fbb86134f4d045b677f to your computer and use it in GitHub Desktop.
class SenditsController < ApplicationController
before_action :set_sendit, only: [:show, :edit, :update, :destroy]
def new
@sendit = Sendit.new
@sendit.alarm = "Even Triggered"
@sendit.save
respond_to do |format|
if @sendit.save
# function I am trying to call
NotificationController.notify
format.html { redirect_to @sendit, notice: 'Sendit was successfully created.' }
format.json { render :show, status: :created, location: @sendit }
else
-----------------error message I am receiving-----------------
NoMethodError in SenditsController#new
undefined method `notify' for NotificationController:Class
------------------NotificationController--------------------
class NotificationController < ApplicationController
skip_before_action :verify_authenticity_token
def notify
client = Twilio::REST::Client.new Rails.application.secrets.twilio_account_sid, Rails.application.secrets.twilio_auth_token
message = client.messages.create from: 'xxxx', to: 'xxxx', body: 'Learning to send SMS you are.'
render plain: message.status
end
@RubyRonin
Copy link
Author

attempting to send sms utilizing twilio api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment