avoid dynamic finders on an assocition with an include

the dynamic finder on the association causes scoping to be called
before delegating the dynamic finder to the class, which works
until the preloader tries to load the owning class, and BOOM,
tries to preload itself

fixes at least one spec for rails 3

Change-Id: Ia22b31a013cb6ac984eb77ca29406372538ea57f
Reviewed-on: https://gerrit.instructure.com/30393
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
Cody Cutrer 2014-02-20 09:41:32 -07:00 committed by James Williams
parent 674d41fb99
commit 031a0341b4
3 changed files with 3 additions and 3 deletions

View File

@ -47,7 +47,7 @@ module ContextModuleItem
preferred_id = preferred_id[Api::ID_REGEX] if preferred_id.is_a?(String)
objs_to_search.each do |obj|
next unless obj.present?
tag = obj.context_module_tags.find_by_id(preferred_id)
tag = obj.context_module_tags.where(:id => preferred_id).first
return tag if tag
end
objs_to_search.each do |obj|

View File

@ -257,7 +257,7 @@ class WikiPage < ActiveRecord::Base
end
def context_module_tag_for(context)
@tag ||= self.context_module_tags.find_by_context_id_and_context_type(context.id, context.class.to_s)
@tag ||= self.context_module_tags.where(context_id: context, context_type: context.class.base_ar_class.name).first
end
def context_module_action(user, context, action)

View File

@ -56,7 +56,7 @@ class ImportedHtmlConverter
end
end
elsif val =~ %r{\$CANVAS_COURSE_REFERENCE\$/modules/items/(.*)}
if tag = context.context_module_tags.find_by_migration_id($1, :select => 'id')
if tag = context.context_module_tags.where(:migration_id => $1).select('id').first
new_url = URI::escape "#{course_path}/modules/items/#{tag.id}"
end
elsif val =~ %r{(?:\$CANVAS_OBJECT_REFERENCE\$|\$WIKI_REFERENCE\$)/([^/]*)/(.*)}