2017-11-02 3 views
0

아래와 같이 API 컨트롤러가 있는데 플래시 알림을 추가하려고 시도했지만 작동하지 않습니다.api 컨트롤러에서 레일 플래시 알림

이 문제에 대해 자세히 알려주십시오.

class API::V1::SmsController < ApplicationController 
    respond_to :json 

    def incoming_sms 
    # respond_with User.find(params[:id]) 
    contact = LocationMessage.new 
    contact.number = params[:number] 

    message = params[:message] 

    contact.latitude= message.split(':')[1].to_s 
    contact.longitude= message.split(':')[2].to_s 
    contact.address= message.split(':')[3].to_s 

    if contact.save 
      flash[:notice] = "New Sms arrived in your System." 

      render :json =>"Location Message saved", status: 201 
    else 
      render json: { errors: contact.errors}, status: 422 
    end 
    end 

감사합니다. Kiran. 그들은 일반적으로보기에 직접으로 표현되기 때문에 JSON 응답과 함께 손을 잡고가는 것을 반대 일반적으로

답변

0

플래시 메시지는

API를 전망 렌더링 해달라고 직접 그래서 페이지를 다시로드 API를 컨트롤러와 잘 재생되지 않습니다 플래시 메시지는 페이지로 렌더링되지 않습니다. documentation에 언급 된 플래시의 특성으로 인해 성공적인 ajax 호출 후 페이지를 새로 고침해도 플래시 메시지가 더 이상 지속되지 않습니다.