を使用してHasManyThroughアソシエーションに追加する際に問題が発生しましたuser_ids
。
私のコミュニケーションモデルは次のようになります。
class communication
has_many :recipients
has_many :users, :through => :recipients
end
通信コントローラーの作成アクションで、次のuser_ids
ように通信オブジェクトに手動で追加しようとしています。
@communication = new Communications(params[:communication])
@communication.user_ids << id
logger.debug @communication.user_ids # is empty
@communication.user_ids
次のようにハードコードされたIDを実行しても、配列が空である理由を理解できません。
@communication = new Communications(params[:communication])
@communication.user_ids << 1
logger.debug @communication.user_ids # is still empty!
まだ空の@communication.user_ids
配列を取得しています。
私の方法で何かが欠けていますか?これを機能させるためのヒントはありますか?
前もって感謝します!