lib/thinking_sphinx/association.rb in dpickett-thinking-sphinx-1.1.12 vs lib/thinking_sphinx/association.rb in dpickett-thinking-sphinx-1.1.23
- old
+ new
@@ -101,16 +101,19 @@
def primary_key_from_reflection
if @reflection.options[:through]
@reflection.source_reflection.options[:foreign_key] ||
@reflection.source_reflection.primary_key_name
+ elsif @reflection.macro == :has_and_belongs_to_many
+ @reflection.association_foreign_key
else
nil
end
end
def table
- if @reflection.options[:through]
+ if @reflection.options[:through] ||
+ @reflection.macro == :has_and_belongs_to_many
@join.aliased_join_table_name
else
@join.aliased_table_name
end
end
\ No newline at end of file