Permalink
Browse files

Merge branch 'master' into set_binds

* master:
  directly create the ARel AST
  Updated comment to mention the enum mapping class method [ci skip]
  • Loading branch information...
2 parents 58e5ba0 + 3204bbf commit 2fff094c9ad27e1027cdf66eda627ded3fb67c62 @tenderlove tenderlove committed Jan 15, 2014
@@ -55,18 +55,16 @@ def join_constraints(foreign_table, foreign_klass, node, join_type, tables, scop
end
end
- if reflection.type
- scope_chain_items <<
- ActiveRecord::Relation.create(klass, table)
- .where(reflection.type => foreign_klass.base_class.name)
- end
-
scope_chain_items.concat [klass.send(:build_default_scope)].compact
rel = scope_chain_items.inject(scope_chain_items.shift) do |left, right|
left.merge right
end
+ if reflection.type
+ constraint = constraint.and table[reflection.type].eq foreign_klass.base_class.name
+ end
+
if rel && !rel.arel.constraints.empty?
bind_values.concat rel.bind_values
constraint = constraint.and rel.arel.constraints
@@ -54,11 +54,12 @@ module ActiveRecord
# remove unused values, the explicit +Hash+ syntax should be used.
#
# In rare circumstances you might need to access the mapping directly.
- # The mappings are exposed through a constant with the attributes name:
+ # The mappings are exposed through a class method with the pluralized attribute
+ # name:
#
# Conversation.statuses # => { "active" => 0, "archived" => 1 }
#
- # Use that constant when you need to know the ordinal value of an enum:
+ # Use that class method when you need to know the ordinal value of an enum:
#
# Conversation.where("status <> ?", Conversation.statuses[:archived])
module Enum

0 comments on commit 2fff094

Please sign in to comment.