2011-10-18 24 views
1
def show 
    #find parent call_flow 
    @call_flow = CallFlow.where('dnis' => params[:dnis]).first 

    if @call_flow.nil? 
     @response = ["no result"] 
    else 
     #find first routable options (should be a message) 
     @call_flow_options = @call_flow.routable_type.constantize.find(@call_flow.routable_id).options 

     #if there is a route after the first route, find it 
     unless @call_flow_options.first.target_routable_type.nil? 
      @target_routable = @call_flow_options.first.target_routable_type.constantize.find(@call_flow_options.first.target_routable_id).options 
      @call_flow_options.to_a.push(@target_routable.to_a) 
     end 
     @response = @call_flow.to_a.push(@call_flow_options) 
    end 
    respond_with @response 

end 

我得到的數據,還因爲所有的"雙引號與"更換瀏覽器不承認它是JSON。Rails的控制器將返回轉義JSON

+0

是什麼反應的問題的一部分是什麼樣子? – tadman

+0

https://gist.github.com/4501bb7379b6e4d91ba5 –

回答

2

如果你正在尋找有整個響應是JSON(而不是HTML使用JSON/JavaScript的),你可以這樣做:

render :json => @response 
+0

謝謝!我不是這是潛在問題的真正答案,但它確實有效。 –