2011-08-04 3 views
0

attr_accessors가있는 클래스가 있습니다. 내 객체의 JSON 문자열을 만들 때 my attr_accessors가 나열되지 않고 mongo로 만든 속성 만 표시됩니다.개체를 JSON으로 변환 할 때 attr_accessors를 볼 수 없습니다.

class Weblink < Media 
    field :title, :type => String 
    field :url, :type => String 
    attachment :image 

    attr_accessor :images, :domain_name, :image_width, :image_height 
end 

{"_id":"4e3ab9895d156dae63000001","_type":"Weblink","description":"Some description","title":"Some title","url":"http://some_url.com"} 
난 exemple를 위해하고 싶은

, 내 "이미지"속성이 포함되어 생성 된 JSON.

제안 사항?

답변

0

시도 :

weblink.to_json(:methods=>[:images, :domain_name, :image_width, :image_height]) 
관련 문제