diff --git a/lib/surveyor/models/response_set_methods.rb b/lib/surveyor/models/response_set_methods.rb index 52dc2ea8..b821b9ba 100644 --- a/lib/surveyor/models/response_set_methods.rb +++ b/lib/surveyor/models/response_set_methods.rb @@ -7,7 +7,7 @@ def self.included(base) # Associations base.send :belongs_to, :survey base.send :belongs_to, :user - base.send :has_many, :responses, :order => "#{Response.quoted_table_name}.created_at ASC", :dependent => :destroy + base.instance_eval {has_many :responses, ->{order "#{Response.quoted_table_name}.created_at ASC"}, :dependent => :destroy} base.send :accepts_nested_attributes_for, :responses, :allow_destroy => true @@validations_already_included ||= nil diff --git a/lib/surveyor/models/survey_methods.rb b/lib/surveyor/models/survey_methods.rb index 46ea6b8b..1aa50382 100644 --- a/lib/surveyor/models/survey_methods.rb +++ b/lib/surveyor/models/survey_methods.rb @@ -6,8 +6,8 @@ module Models module SurveyMethods def self.included(base) # Associations - base.send :has_many, :sections, :class_name => "SurveySection", :order => "#{SurveySection.quoted_table_name}.display_order", :dependent => :destroy - base.send :has_many, :sections_with_questions, :include => :questions, :class_name => "SurveySection", :order => "#{SurveySection.quoted_table_name}.display_order" + base.instance_eval {has_many :sections, ->{order "#{SurveySection.quoted_table_name}.display_order"}, :class_name => "SurveySection", :dependent => :destroy} + base.instance_eval {has_many :sections_with_questions, ->{includes(:questions).order("#{SurveySection.quoted_table_name}.display_order")}, :class_name => "SurveySection"} base.send :has_many, :response_sets base.send :has_many, :translations, :class_name => "SurveyTranslation"