Can I use has_many :through and :dependent => destroy together?-Collection of common programming errors
I’m trying to run a functional test on my PollsController and keep getting this error:
block in assert_valid_keys': Unknown key: through (ArgumentError)
I’m wondering if its because I have a dependent destroy on the Question model and a has_many relationship ship through it to sms. Any advice? Thanks!!
Here’s the Poll model
class Poll < ActiveRecord::Base
attr_accessible :description, :end_time, :start_time, :title, :user_id, :questions_attributes, :is_live
belongs_to :user
has_many :questions, :dependent => :destroy
# This is the pluralized form of sms, it's not smss
has_many :sms, :through => :questions
has_many :feedbacks
accepts_nested_attributes_for :questions, :allow_destroy => true
Question model
class Question < ActiveRecord::Base
attr_accessible :poll_id, :title, :answers_attributes
belongs_to :poll
has_many :answers, :dependent => :destroy
# THis is the plularized form of sms, it's not smss
has_many :sms
#If someone creates a form with a blank question field at the end, this will prevent it from being rendered on teh show page
accepts_nested_attributes_for :answers, :allow_destroy => true
end
Originally posted 2013-11-09 23:22:58.