#Arrays# ###Using the Docs###
[1,2,3,4].each {|x| puts x + 1 }
2
3
4
5
=> [1,2,3,4]
#Arrays# ###Using the Docs###
[1,2,3,4].each {|x| puts x + 1 }
2
3
4
5
=> [1,2,3,4]
#Mixing and Matching Queries#
puts Product.where(:price => 5).
where(:name => "apple").
order(:created_at).
limit(55).
joins(:users).
where(:user => {:name => "richard"})
##Each method takes the output of the previous and adds to it##
#Grouping#
prods = Product.group(:price).count
Returns
puts prods
=> {573=>3, 574=>4, 575=>6, 576=>4}
The group method returns a hash of all prices, along with the count of each price. For example, there must be 3 items priced at 573