2012-04-17 4 views
3

사용자가 서버를 요청할 때 JSON으로 출력하고 싶은 간단한 클래스가 있습니다. 컨트롤러에서[DEPRECATION] MultiJson.decode가 사용되지 않습니다.

class GeoName 

include ActiveModel::Validations 
include ActiveModel::Serialization 

validates :country_name, :presence => true, :length => {:minimum => 1} 
validates :country_code, :presence => true, :length => {:minimum => 1} 
validates :province, :presence => true, :length => {:minimum => 1} 
validates :district, :presence => true, :length => {:minimum => 1} 
validates :zip_code, :presence => true, :length => {:minimum => 1} 
validates :city, :presence => true, :length => {:minimum => 1} 
validates :street, :presence => true, :length => {:minimum => 1} 

attr_accessor :country_name, :country_code, :province, :district, :zip_code, :city, :street 


def attributes 
@attributes ||= {'country_name' => country_name, 'country_code' => country_code, 'province' => province,'district' => district,'zip_code' => zip_code,'city' => city, 'street' => street} 
end 


end 

나는 다음을 수행하십시오

def index 
    geoname = GeoName.new 
    geoname.street = "blablabla" 
    geoname.city = "blablabla" 
    render :json => geoname.to_json 
    end 

controller :testcontroller do 
    match 'testme', :to => :index 
    end 

내가 URL을 로컬 호스트를 요청

routes.rb에서 : 3000/testme라는 나는 유효한 JSON 응답을받을 수 있습니다. 그러나 콘솔에서 권장하지 않습니다.

rvm/gems/[email protected]/gems/activesupport-3.1.0/lib/active_support/json/decoding.rb:12:in `decode': [DEPRECATION] MultiJson.decode is deprecated and will be removed in the next major version. Use MultiJson.load instead. 

Ruby 버전 1.9.3-p125 및 레일 - 3.1.0.

답변

0

빠른 Google은 MultiJSON에서 경고를 표시합니다 (더 이상 사용되지 않는 코드와 메시지가 보석 코드에서 제거 된 경우). 기본적으로 이것은 코드에 MultiJSON.decode을 사용하는 개발자를위한 경고입니다. 코드에 MultiJSON.decode을 사용하지 않으면 무시하십시오.

종속 보석이 업데이트되고 업데이트 된 항목을 프로젝트에 묶으면 메시지가 사라질 수 있습니다.

관련 문제