2
두 가지 유형의 레일스 객체 게시물 및 주석이 있습니다. 각 게시물 has_many
의 의견과 각 댓글 belongs_to
의 게시물을 가정 해 봅시다. 나는 내 댓글 JSON 문자열을 만들 때레일 중첩 모델/JSON 요청 구성 혼동
나는이 수행
{"id":0,"title":"something","body":"something","post_id":1}
을하지만 난 다시 얻을
{"id":0,"title":"something","body":"something","post_id":NULL}
나는에 POST의 JSON 요청을 보내고 :이 때문에에 /comments.json
post 객체가 싱글 톤 인 경우.
여기 내 경로는 다음과 같습니다
resources :posts
resources :comments
누구 내가 여기 해결할 수 뭔지 알아?
'post_id'이 (가) 보호 될 수 있습니다. 주석 모델의'attr_accessible'에 추가 해보십시오. – klump
@klump 아마도 대답 일 것입니다. – tadman