lib/thinking_sphinx/association.rb in dpickett-thinking-sphinx-1.1.4 vs lib/thinking_sphinx/association.rb in dpickett-thinking-sphinx-1.1.12
- old
+ new
@@ -97,9 +97,26 @@
def has_column?(column)
@reflection.klass.column_names.include?(column.to_s)
end
+ def primary_key_from_reflection
+ if @reflection.options[:through]
+ @reflection.source_reflection.options[:foreign_key] ||
+ @reflection.source_reflection.primary_key_name
+ else
+ nil
+ end
+ end
+
+ def table
+ if @reflection.options[:through]
+ @join.aliased_join_table_name
+ else
+ @join.aliased_table_name
+ end
+ end
+
private
# Returns all the objects that could be currently instantiated from a
# polymorphic association. This is pretty damn fast if there's an index on
# the foreign type column - but if there isn't, it can take a while if you
\ No newline at end of file