A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord| HTTP status code symbols for Rails | |
| Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
| Status Code Symbol | |
| 1xx Informational | |
| 100 :continue | |
| 101 :switching_protocols | |
| 102 :processing |
| # Given an array of arrays s = [ [1,2,3], [4,5,6], ... ] | |
| # compute the Cartesian product among the elements of s. | |
| require 'pp' | |
| s = [[1, 2], [3, 4, 5], [6, 7, 8, 9]] | |
| pp s[1..-1].inject(s[0]){ |m,v| m = m.product(v).map(&:flatten) } | |
| [[1, 3, 6], | |
| [1, 3, 7], | |
| [1, 3, 8], |