spacerobot
spacerobot

Reputation: 297

Rails has many through params in create action problem

I have a csv import function that is creating many cardrequests for each id in the csv. I have a has many through relationship for the cardholdergroup model. How do I tell this create action to create the records and set the cardholdergroup_ids: [] param on create?

  CSV.foreach(file_path) do |row|
   @cardrequest = Cardrequest.create(empid: row[0], 
   startdate: cardrequest_params[:startdate], 
   enddate: cardrequest_params[:enddate], user_id: current_user.id, 
   cardholdergroup_ids: cardrequest_params[cardholdergroup_ids: []
  end

Upvotes: 0

Views: 27

Answers (1)

blackbiron
blackbiron

Reputation: 827

it should be cardrequest_params[:cardholdergroup_ids]

Upvotes: 1

Related Questions