Skip to content

Instantly share code, notes, and snippets.

@lucasmazza
Created March 20, 2015 02:54
Show Gist options
  • Save lucasmazza/99889a69149686c6474e to your computer and use it in GitHub Desktop.
Save lucasmazza/99889a69149686c6474e to your computer and use it in GitHub Desktop.
diff --git a/lib/lol_dba.rb b/lib/lol_dba.rb
index d9a75a4..6a1e07e 100644
--- a/lib/lol_dba.rb
+++ b/lib/lol_dba.rb
@@ -125,13 +125,7 @@ EOM
else
# go to joining model through has_many and find belongs_to
blg_to_reflection = class_name.reflections[reflection_options.options[:through].to_s]
- if blg_to_reflection.options[:class_name]
- # has_many :class_name
- blg_to_class = blg_to_reflection.options[:class_name].constantize
- else
- # has_many
- blg_to_class = blg_to_reflection.name.to_s.singularize.camelize.constantize
- end
+ blg_to_class = blg_to_reflection.class_name.constantize
#multiple level :through relation, can be ignored for now(it will be checked in the right relation)
next if blg_to_class.reflections[reflection_name.to_s.singularize.to_s].nil?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment