0
에 더 많은 문제가 있음이 (가) user_ids
을 사용하여 여러 연결을 통해 발생했습니다.Ruby on Rails가 배열을 통해 많은 문제가 있음
내 통신 모델은 다음과 같습니다 : 내가 할 수있는
@communication = new Communications(params[:communication])
@communication.user_ids << id
logger.debug @communication.user_ids # is empty
'내가 수동과 같이 통신 객체에 user_ids
를 추가하려고하고있는 통신 컨트롤러 내 생성 작업에
class communication
has_many :recipients
has_many :users, :through => :recipients
end
왜 이런 식으로 하드 코드 된 ID를 할 때라도 @communication.user_ids
배열이 비어있는 이유는 무엇입니까?
@communication = new Communications(params[:communication])
@communication.user_ids << 1
logger.debug @communication.user_ids # is still empty!
아직 배열이 비어 있습니다. @communication.user_ids
.
내 방법으로 뭔가가 누락 되었습니까? 이 작업을 수행하는 데 도움이되는 팁이 있습니까?
미리 감사드립니다.