我有一个接受并保存数据的api。
我想将当前用户界面上的数据作为flash获取怎么做?
我尝试wisper gem
并且不支持Flash提醒。
$ 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