aboutsummaryrefslogtreecommitdiffstats
path: root/README.markdown
diff options
context:
space:
mode:
authorRafael Mendonça França <rafael.franca@plataformatec.com.br>2013-12-04 23:33:25 -0200
committerRafael Mendonça França <rafael.franca@plataformatec.com.br>2013-12-04 23:33:25 -0200
commita4ddbe4e80dba6840019862dec54748fc8799163 (patch)
tree95536e64f2318099532b2186ab5cc5c962c35926 /README.markdown
parent986773ecc6fb6d34b56c45393bcc320b8bd2a66d (diff)
downloadrails-a4ddbe4e80dba6840019862dec54748fc8799163.tar.gz
rails-a4ddbe4e80dba6840019862dec54748fc8799163.tar.bz2
rails-a4ddbe4e80dba6840019862dec54748fc8799163.zip
Remove columns usage from the README
Closes #189
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown9
1 files changed, 3 insertions, 6 deletions
diff --git a/README.markdown b/README.markdown
index bcdbaba0b2..c7346d9efd 100644
--- a/README.markdown
+++ b/README.markdown
@@ -111,12 +111,10 @@ Suppose we have a table `products` with prices in different currencies. And we h
```ruby
products = Arel::Table.new(:products)
-products.columns
-# => [products[:id], products[:name], products[:price], products[:currency_id]]
+# Attributes: [:id, :name, :price, :currency_id]
currency_rates = Arel::Table.new(:currency_rates)
-currency_rates.columns
-# => [currency_rates[:from_id], currency_rates[:to_id], currency_rates[:date], currency_rates[:rate]]
+# Attributes: [:from_id, :to_id, :date, :rate]
```
Now, to order products by price in user preferred currency simply call:
@@ -139,8 +137,7 @@ comments = Arel::Table.new(:comments)
And this table has the following attributes:
```ruby
-comments.columns
-# => [comments[:id], comments[:body], comments[:parent_id]]
+# [:id, :body, :parent_id]
```
The `parent_id` column is a foreign key from the `comments` table to itself. Now, joining a table to itself requires aliasing in SQL. In fact, you may alias in Arel as well: