【发布时间】:2015-08-29 20:44:19
【问题描述】:
我在我的小型 Rails 应用程序的一个小型控制器中调用 responseJson = ActiveSupport::Json.decode(response) 的那一行收到“未初始化的常量 ActiveSupport::Json”错误。
response 变量返回带有{"token":"this_is_your_session_token"} 类型响应的字符串。
我已将gem 'activesupport', '~> 4.2.3' 添加到我的Gemfile,尝试使用'active_support/core_ext/object/json 使用不同的require 语句,并在IRB 中尝试了此操作(错误相同)。我不确定如何进一步调试。任何帮助将不胜感激。
需要'active_support/json'
require 'active_support'
require 'active_support/all'
require 'rest-client'
class WelcomeController < ApplicationController
def login_attempt
username = params[:u]
password = params[:p]
puts "waiting on request"
response = RestClient.post 'http://localhost:3001/v1/login', :email => username, :password => password
responseJson = ActiveSupport::Json.decode(response)
end
end
【问题讨论】:
标签: ruby-on-rails ruby json rest-client activesupport