accept nested attributes for has_many relationship

后端 未结 3 829
谎友^
谎友^ 2020-12-19 16:40

Below are my two model classes

class Patient < ActiveRecord::Base
  belongs_to :user, :dependent => :destroy
  has_many :enrollments, :dependent =>          


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-19 16:48

    I ended up doing the following:

    <%= check_box_tag "patient[client_ids][]", client.id, @patient.clients.include?(client) %>
    

    I am not sure if this is the best way...any comments (I had to update my model to include attr_accessible :client_ids

提交回复
热议问题