From 8750c9a1cfb055fb45a798fee952953b6db829ad Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 6 Nov 2011 18:58:55 +0530 Subject: fix markups for plus in AR guide --- .../guides/source/active_record_querying.textile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index a132d85ef9..8526d8511b 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -1287,19 +1287,19 @@ User.where(:id => 1).joins(:posts).explain may yield -+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ +------------------------------------------------------------------------------------------ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | -+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ +------------------------------------------------------------------------------------------ | 1 | SIMPLE | users | const | PRIMARY | PRIMARY | 4 | const | 1 | | | 1 | SIMPLE | posts | ALL | NULL | NULL | NULL | NULL | 1 | Using where | -+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ +------------------------------------------------------------------------------------------ 2 rows in set (0.00 sec) under MySQL. Active Record performs a pretty printing that emulates the one of the database -shells. So, the same query running with the PostreSQL adapter would yield instead +shells. So, the same query running with the PostgreSQL adapter would yield instead QUERY PLAN @@ -1324,17 +1324,17 @@ User.where(:id => 1).includes(:posts).explain yields -+----+-------------+-------+-------+---------------+---------+---------+-------+------+------- +------------------------------------------------------------------------------------ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | -+----+-------------+-------+-------+---------------+---------+---------+-------+------+------- +------------------------------------------------------------------------------------ | 1 | SIMPLE | users | const | PRIMARY | PRIMARY | 4 | const | 1 | | -+----+-------------+-------+-------+---------------+---------+---------+-------+------+------- +------------------------------------------------------------------------------------ 1 row in set (0.00 sec) -+----+-------------+-------+------+---------------+------+---------+------+------+------------- +------------------------------------------------------------------------------------- | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | -+----+-------------+-------+------+---------------+------+---------+------+------+------------- +------------------------------------------------------------------------------------- | 1 | SIMPLE | posts | ALL | NULL | NULL | NULL | NULL | 1 | Using where | -+----+-------------+-------+------+---------------+------+---------+------+------+------------- +------------------------------------------------------------------------------------- 1 row in set (0.00 sec) -- cgit v1.2.3 From 1ffd5ec91069167043c8ecd0d949098f566d88eb Mon Sep 17 00:00:00 2001 From: Joost Baaij Date: Tue, 8 Nov 2011 16:27:15 +0100 Subject: Replace example with SQL placeholder syntax. This works just fine, is less code, and reduces the risk of someone implementing a SQL injection vulnerability. --- railties/guides/source/association_basics.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index 6829eb8ef4..451653655f 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -1234,7 +1234,7 @@ If you need to evaluate conditions dynamically at runtime, use a proc: class Customer < ActiveRecord::Base has_many :latest_orders, :class_name => "Order", - :conditions => proc { "orders.created_at > #{10.hours.ago.to_s(:db).inspect}" } + :conditions => proc { ["orders.created_at > ?, 10.hours.ago] } end -- cgit v1.2.3