I have a api which accepts and saves data in rails.
I would like to get that data on the current UI as flash how to do it ?
I tried to wisper gem
and flash alerts are not supported.
$ cat app/controllers/api/v1/sms_controller.rb
class API::V1::SmsController < ApplicationController
def incoming_sms
contact = LocationMessage.new
contact.number = params[:number]
message = params[:message]
if contact.save
render :json =>"Location Message saved", status: 201
else
render json: { errors: contact.errors}, status: 422
end
end
end
Class LocationMessage < ApplicationRecord
include Wisper::Publisher
after_save :publish_creation_successful
def publish_creation_successful
broadcast(:emergency_location_creation_successful)
end
end
def new
flash[:notice] = "coollllll blah blah"
@incident = Incident.new
Wisper.subscribe(SmsListener.new)
end
class SmsListener
def emergency_location_creation_successful()
flash[:notice] = "Location is saved"
end
end
Reference for detail discussion, https://github.com/krisleech/wisper/issues/165