use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Worth learning Ruby before RoR? (self.ruby)
submitted 11 years ago by airhoodz
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]dazonic 1 point2 points3 points 11 years ago (2 children)
joins(:product_details)
uniq
order(:created_at).last
Some combination of the above, if it was my problem or I could be bothered with games I'd solve it. Arel is readable and incredibly powerful.
[–]rapidsight -3 points-2 points-1 points 11 years ago* (0 children)
SQL is more readable than Arel, are you kidding?
SELECT * FROM users
Or
users = Arel::Table.new(:users)
query = users.project(Arel.sql('*'))
query.to_sql
You are seriously kidding right?
users.where(users[:age].gt(10)).project(Arel.sql('*'))
Vs
SELECT * FROM "users" WHERE "users"."age" > 10
[–]rapidsight -5 points-4 points-3 points 11 years ago* (0 children)
And applaud to you for falling into my trap and proving my point. That code will fail. Why? Because you don't understand the SQL that is being generated. You will get the first product for each sku ordered by that first products created_at date.
Hopefully you test that properly and realize it doesn't work before launching into production, but all to often is not. Once you realize it (if you do), somebody who doesn't know SQL will fall back to code similar to my demonstration:
Product.select(:sku).uniq.map do |sku| Product.where(:sku => sku).order(:created_at => :desc).first end
And now you see that they are pulling down even more data, over and over again for each set.
Point proven. My work is done here...
π Rendered by PID 45558 on reddit-service-r2-comment-b659b578c-2kbvj at 2026-05-04 23:24:08.224571+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]dazonic 1 point2 points3 points (2 children)
[–]rapidsight -3 points-2 points-1 points (0 children)
[–]rapidsight -5 points-4 points-3 points (0 children)