lib/comma-heaven/sqler/association_columns.rb in comma-heaven-0.8.1 vs lib/comma-heaven/sqler/association_columns.rb in comma-heaven-0.8.2
- old
+ new
@@ -14,8 +14,18 @@
end
def foreign_key_for(an_association)
an_association.respond_to?(:foreign_key) ? an_association.foreign_key : an_association.primary_key_name
end
+
+ def table_alias(method = :pluralize)
+ t = association.name.to_s.send(method)
+
+ return prefix + [((parent && parent.parent) ? parent.table_alias(method) : nil), t, index].compact.join('_')
+ end
+
+ def prefix
+ return "_"
+ end
end
end
end
\ No newline at end of file