Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 聊天室消息控制器中的NoMethodError_Ruby On Rails_Ruby_Ajax_Json_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 聊天室消息控制器中的NoMethodError

Ruby on rails 聊天室消息控制器中的NoMethodError,ruby-on-rails,ruby,ajax,json,ruby-on-rails-4,Ruby On Rails,Ruby,Ajax,Json,Ruby On Rails 4,我正在做一个AJAX调用,如下所示,并尝试解析Rails中接收到的JSON,如下所示 AJAX local_data = {chat:{room_name: chatRoomName ,message: message}} $.ajax({ type: "POST", url: '/chat_notify', dataType: 'json', async : false, data: local_dat

我正在做一个AJAX调用,如下所示,并尝试解析Rails中接收到的JSON,如下所示

AJAX

local_data = {chat:{room_name: chatRoomName ,message: message}}
      $.ajax({
        type: "POST",
        url: '/chat_notify',
        dataType: 'json',
        async : false,
        data: local_data,
        success: function(data) {
            alert("working");
        }
      });
红宝石

def notify
    #data = ActiveSupport::JSON.decode(params)

    #chat_room = ChatRoom.where(:slug =>  data.chat.name)
    #puts @chat_room

    puts params.chat
    RestClient.post 'https://api.pushbots.com/push/all',
    { "platform" => [0,1] ,
      "msg" => "Harsha sent a message." ,
      "sound" => "pulse",
      "alias" => "harsha@mink7.com",
      "badge" => "1",
      "payload" => { "type" => "Chat", "chat_id" => 1 } }.to_json,
      headers = { "x-pushbots-appid" => APP_CONFIG['PUSHBOTS_APPID'],
                  "x-pushbots-secret" => APP_CONFIG['PUSHBOTS_SECRET'],
                  :content_type => :json }

    render json: true
  end

错误

您需要粘贴错误跟踪

但我认为问题可能出在下面

put params.chat

对于
参数
,没有聊天方法,只需将其删除即可

…..“有效负载”=>{“类型”=>“聊天”,“聊天id”=>1}}。到json


您需要
require'json'
才能使
可用。要使json
可用,请显示错误信息