提交 0d65969e 编写于 作者: C Carlos Antonio da Silva

Improve relation docs about to_sql and where_values_hash

* User class instead of Users.
* #where_values_hash does not change the value to downcase as the
  example was showing.

[ci skip]
上级 f209b176
......@@ -474,16 +474,16 @@ def reset
# Returns sql statement for the relation.
#
# Users.where(name: 'Oscar').to_sql
# User.where(name: 'Oscar').to_sql
# # => SELECT "users".* FROM "users" WHERE "users"."name" = 'Oscar'
def to_sql
@to_sql ||= klass.connection.to_sql(arel, bind_values.dup)
end
# Returns a hash of where conditions
# Returns a hash of where conditions.
#
# Users.where(name: 'Oscar').where_values_hash
# # => {name: "oscar"}
# User.where(name: 'Oscar').where_values_hash
# # => {name: "Oscar"}
def where_values_hash
equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
node.left.relation.name == table_name
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册