I created a join table like so:
class CreateJoinTablePurchaseUser < ActiveRecord::Migration[5.0]
def change
create_join_table :purchases, :users, table_name: :participation_requests do |t|
# t.index [:purchase_id, :user_id]
# t.index [:user_id, :purchase_id]
t.boolean :approved, default: false
end
end
And here is my model:
class ParticipationRequest < ApplicationRecord
end
I created a row in the table successfully. However, when I try to update the boolean value like so:
pr = ParticipationRequest.find_by(user_id: 1, purchase_id: 1)
pr.update_attributes(approved: true)
pr returns the row and I get a ROLLBACK on the update with this message:
TypeError: nil is not a symbol nor a string
I recognized that the join table is different from my other tables in that it is not indexed like my regular tables. The primary key seems to be a combination of the user_id and purchase_id. I have no problem using update_attributes on any of my other tables. Is there something different about this join table that will not allow me to update an attribute this way?