drnic/composite_primary_keys — Issue #88: :belongs_to problem in CPK
Author: delphaber
Created: 2012-03-07 12:40:40+00:00
State: open

Hi :)

composite_primary_keys (5.0.1)
activerecord (3.2.1)

class Form < ActiveRecord::Base
self.primary_keys = 'id_camp', 'id'

has_many :questions, :foreign_key => ['id_camp', 'id']
end

class Question < ActiveRecord::Base
self.primary_keys = 'id_camp', 'id_quest', 'id'

belongs_to :form, :foreign_key => ['id_camp', 'id_quest'];
end

I'm trying to save a new question object
form = Form.first
question = Question.new(:form => form)
question.save

Gives this error
["id_camp", "id_quest"] is not a symbol

While this code not:
form = Campaign.first.forms.first
question = form.questions.build
question.save