Permalink
Browse files

Added instructions for how to select multiple attributes in Squeel

It took me a little while to figure out how to select multiple attributes in a query. I've added little paragraph in which details this
  • Loading branch information...
1 parent 23281d5 commit 417f00825f14db79b716b473caa549a2e68decc3 @peternixey peternixey committed Aug 1, 2013
Showing with 13 additions and 0 deletions.
  1. +13 −0 README.md
View
@@ -467,6 +467,19 @@ p.flanderized_name
As you can see, just like functions, these operations can be given aliases.
+To select more than one attribute (or calculated attribute) simply chain your select statements:
+
+```ruby
+p = Person.select{name.op('||', '-diddly').as(flanderized_name)
+ }.select{ coalesce(name, '<no name given>').as(name_with_default)
+}.first
+p.flanderized_name
+# => "Aric Smith-diddly"
+p.name_with_default
+# => "Aric Smith"
+```
+
+
## Compatibility with Active Record
Most of the new functionality provided by Squeel is accessed with the new block-style `where{}`

0 comments on commit 417f008

Please sign in to comment.