Upgraded our app from Rails 2.2.2 to 2.3.4, and I'm now encountering an error when adding a child to a parent.
Top of the stack:
wrong number of arguments (1 for 0) /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/ associations/has_many_association.rb:61:in `save' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/ associations/has_many_association.rb:61:in `insert_record' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/ associations/association_collection.rb:119:in `<<' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/ associations/association_collection.rb:433:in `add_record_to_target_with_callbacks'
My code (in snippets):
class Trip < ActiveRecord::Base has_many :activity_reservations end
class ActivityReservation < ActiveRecord::Base belongs_to :trip end
trip.activity_reservations << ActivityReservation.new
The has_many_associations code referenced:
def insert_record(record, force = false, validate = true) set_belongs_to_association_for(record) force ? record.save! : record.save(validate) end
The ActiveRecord save method:
def save create_or_update end
The comments for the save method indicate that it can take an optional perform_validations method, and the Validations module defines (with alias_method_chain :save, :validation).
So, finally my question: what is going on here? ActiveRecord is calling a save method passing an arg, but the save method in ActiveRecord isn't defined to take a boolean. I'm guessing that something with the Validations and alias_method_chain is supposed to handle this, but in the way I'm doing things in my code, its not working.
(ActiveRecord 2.2.2, which we were on previously, just called ActiveRecord.save - not attempting to pass a boolean)
Any help or pointers would be greatly appreciated.
Paul Christmann