CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Wed, 06 Aug 2025 21:34:06 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090103202144
location: https://web.archive.org/web/20090103202144/https://github.com/defunkt/ambitious_activerecord/tree
server-timing: captures_list;dur=0.700080, exclusion.robots;dur=0.035146, exclusion.robots.policy;dur=0.022748, esindex;dur=0.011107, cdx.remote;dur=12.834425, LoadShardBlock;dur=230.946398, PetaboxLoader3.datanode;dur=68.315408, PetaboxLoader3.resolve;dur=83.077352
x-app-server: wwwb-app200
x-ts: 302
x-tr: 273
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=4
set-cookie: wb-p-SERVER=wwwb-app200; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 301
server: nginx
date: Wed, 06 Aug 2025 21:34:07 GMT
content-type: text/html; charset=utf-8
content-length: 126
x-archive-orig-server: nginx/0.6.31
x-archive-orig-date: Sat, 03 Jan 2009 20:21:41 GMT
x-archive-orig-connection: close
x-archive-orig-status: 301 Moved Permanently
location: https://web.archive.org/web/20090103202144/https://github.com/defunkt/ambitious_activerecord/tree/master
x-archive-orig-x-runtime: 156ms
x-archive-orig-cache-control: no-cache
x-archive-orig-content-length: 126
cache-control: max-age=1800
memento-datetime: Sat, 03 Jan 2009 20:21:44 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 28 Apr 2008 00:00:03 GMT", ; rel="prev memento"; datetime="Wed, 19 Nov 2008 05:49:28 GMT", ; rel="memento"; datetime="Sat, 03 Jan 2009 20:21:44 GMT", ; rel="last memento"; datetime="Sat, 03 Jan 2009 20:21:44 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_7_20090103190611_crawl102-c/52_7_20090103202054_crawl103.arc.gz
server-timing: captures_list;dur=0.854517, exclusion.robots;dur=0.037497, exclusion.robots.policy;dur=0.022549, esindex;dur=0.020558, cdx.remote;dur=57.427868, LoadShardBlock;dur=339.186411, PetaboxLoader3.datanode;dur=197.382732, PetaboxLoader3.resolve;dur=616.594150, load_resource;dur=505.954106
x-app-server: wwwb-app200
x-ts: 301
x-tr: 943
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Wed, 06 Aug 2025 21:34:08 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.6.31
x-archive-orig-date: Sat, 03 Jan 2009 20:21:43 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-x-runtime: 709ms
x-archive-orig-etag: "1c0170b78e428977df0707d8214f18ea"
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-orig-content-length: 23854
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 03 Jan 2009 20:21:44 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 28 Apr 2008 00:00:03 GMT", ; rel="prev memento"; datetime="Wed, 19 Nov 2008 05:49:49 GMT", ; rel="memento"; datetime="Sat, 03 Jan 2009 20:21:44 GMT", ; rel="next memento"; datetime="Mon, 05 Jan 2009 07:31:16 GMT", ; rel="last memento"; datetime="Mon, 05 Jan 2009 07:31:16 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_7_20090103190611_crawl102-c/52_7_20090103202054_crawl103.arc.gz
server-timing: captures_list;dur=1.563818, exclusion.robots;dur=0.030199, exclusion.robots.policy;dur=0.018372, esindex;dur=0.012387, cdx.remote;dur=33.142840, LoadShardBlock;dur=57.016324, PetaboxLoader3.datanode;dur=81.587852, load_resource;dur=493.433843, PetaboxLoader3.resolve;dur=457.013986
x-app-server: wwwb-app200
x-ts: 200
x-tr: 641
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
defunkt's ambitious_activerecord at master — GitHub
We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]
This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (

This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (

Run the following if you haven't already:
gem sources -a https://gems.github.com
Install the gem(s):
sudo gem install defunkt-ambitious-activerecord
Description: | Ambitious ActiveRecord adapter, for Ambition. |
Clone URL: |
git://github.com/defunkt/ambitious_activerecord.git
Give this clone URL to anyone.
git clone git://github.com/defunkt/ambitious_activerecord.git
|
name | age | message | |
---|---|---|---|
![]() |
.gitignore | Sat Apr 26 02:12:36 -0700 2008 | build me a gem [defunkt] |
![]() |
LICENSE | Sat Apr 26 02:11:10 -0700 2008 | new git repo [defunkt] |
![]() |
Manifest | Sat Apr 26 02:11:10 -0700 2008 | new git repo [defunkt] |
![]() |
README | Sat Apr 26 02:11:10 -0700 2008 | new git repo [defunkt] |
![]() |
Rakefile | Sat Apr 26 03:13:42 -0700 2008 | update version [defunkt] |
![]() |
ambitious-activerecord.gemspec | Sat Apr 26 03:13:42 -0700 2008 | update version [defunkt] |
![]() |
lib/ | Sat Apr 26 02:11:10 -0700 2008 | new git repo [defunkt] |
![]() |
test/ | Sat Apr 26 02:11:10 -0700 2008 | new git repo [defunkt] |
README
h2. An Ambitious ActiveRecord Adapter I could tell you all about how awesome the internals are, or how fun it was to write, or how it'll make you rich and famous, but instead I'm just going to show you some examples. h2. Get It @$ sudo gem install ambitious-activerecord@ This will suck in the adapter and its dependencies (ActiveRecord & Ambition). It's fully usable outside of Rails (I use it in a Camping app or two), as long as you're riding ActiveRecord. Now require it in your app: <pre> require 'rubygems' require 'ambition/adapters/activerecord' </pre> h2. Examples Basically, you write your SQL in Ruby. No, not in Ruby. As Ruby. <ruby> User.select { |u| u.city == 'San Francisco' }.each do |user| puts user.name end </ruby> And that's it. The key is that queries aren't actually run until the data they represent is requested. Usually this is done with what I call a kicker method. You can call them that, too. Kicker methods are guys like @detect@, @each@, @each_with_index@, @map@, @entries@, @to_a@, and @first@ (with no argument). Methods like @select@, @sort_by@, and @first@ (with an argument) are not kicker methods and return a @Context@ object without running any SQL. Our @Context@ object has two useful methods: @to_s@ and @to_hash@. With these, we can check out what exactly we're building. Not everyone has @to_s@, though. Mostly ignore these methods and treat everything like you normally would. See, @to_s@: <ruby> >> User.select { |m| m.name == 'jon' }.to_s => "SELECT * FROM users WHERE users.name = 'jon'" </ruby> See, @to_hash@: <ruby> >> User.select { |m| m.name == 'jon' }.to_hash => { :conditions => "users.name = 'jon'" } </ruby> h2. Equality - select { |u| u.field == 'bob' } <ruby> User.select { |m| m.name == 'jon' } "SELECT * FROM users WHERE users.name = 'jon'" User.select { |m| m.created_at > 2.days.ago } "SELECT * FROM users WHERE users.created_at > '2007-09-26 20:37:47'" User.select { |m| m.name == 'jon' } "SELECT * FROM users WHERE users.name = 'jon'" User.select { |m| m.name != 'jon' } "SELECT * FROM users WHERE users.name <> 'jon'" User.select { |m| m.name == 'jon' && m.age == 21 } "SELECT * FROM users WHERE (users.name = 'jon' AND users.age = 21)" User.select { |m| m.name == 'jon' || m.age == 21 } "SELECT * FROM users WHERE (users.name = 'jon' OR users.age = 21)" User.select { |m| m.name == 'jon' || m.age == 21 && m.password == 'pass' } "SELECT * FROM users WHERE (users.name = 'jon' OR (users.age = 21 AND users.password = 'pass'))" User.select { |m| (m.name == 'jon' || m.name == 'rick') && m.age == 21 } "SELECT * FROM users WHERE ((users.name = 'jon' OR users.name = 'rick') AND users.age = 21)" </ruby> h2. Associations - select { |u| u.field == 'bob' && u.association.field == 'bob@bob.com' } The @to_s@ method doesn't work on associations yet, but that's okay: they can still query through ActiveRecord just fine. <ruby> User.select do |u| u.email == 'chris@ozmm.org' && u.profile.name == 'chris wanstrath' end.map(&:title) "SELECT users.id AS t0_r0, ... FROM users LEFT OUTER JOIN profiles ON profiles.user_id = users.id WHERE ((users.email = 'chris@ozmm.org' AND profiles.name = 'chris wanstrath'))" </ruby> h2. Comparisons - select { |u| u.age > 21 } <ruby> User.select { |m| m.age > 21 } "SELECT * FROM users WHERE users.age > 21" User.select { |m| m.age < 21 }.to_s "SELECT * FROM users WHERE users.age < 21" User.select { |m| [1, 2, 3, 4].include? m.id } "SELECT * FROM users WHERE users.id IN (1, 2, 3, 4)" </ruby> h2. LIKE and REGEXP (RLIKE) - select { |m| m.name =~ 'chris' } <ruby> User.select { |m| m.name =~ 'chris' } "SELECT * FROM users WHERE users.name LIKE 'chris'" User.select { |m| m.name =~ 'chri%' } "SELECT * FROM users WHERE users.name LIKE 'chri%'" User.select { |m| m.name !~ 'chris' } "SELECT * FROM users WHERE users.name NOT LIKE 'chris'" User.select { |m| !(m.name =~ 'chris') } "SELECT * FROM users WHERE users.name NOT LIKE 'chris'" User.select { |m| m.name =~ /chris/ } "SELECT * FROM users WHERE users.name REGEXP 'chris'" </ruby> h2. #detect <ruby> User.detect { |m| m.name == 'chris' } "SELECT * FROM users WHERE users.name = 'chris' LIMIT 1" </ruby> h2. LIMITs - first, first(x), [offset, limit], [range], slice <ruby> User.select { |m| m.name == 'jon' }.first "SELECT * FROM users WHERE users.name = 'jon' LIMIT 1" User.select { |m| m.name == 'jon' }.first(5) "SELECT * FROM users WHERE users.name = 'jon' LIMIT 5" User.select { |m| m.name == 'jon' }[10, 20] "SELECT * FROM users WHERE users.name = 'jon' LIMIT 10, 20" User.select { |m| m.name == 'jon' }[10..20] "SELECT * FROM users WHERE users.name = 'jon' LIMIT 10, 10" </ruby> h2. ORDER - sort_by { |u| u.field } <ruby> User.select { |m| m.name == 'jon' }.sort_by { |m| m.name } "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name" User.select { |m| m.name == 'jon' }.sort_by { |m| [ m.name, m.age ] } "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name, users.age" User.select { |m| m.name == 'jon' }.sort_by { |m| [ m.name, -m.age ] } "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name, users.age DESC" User.select { |m| m.name == 'jon' }.sort_by { |m| [ -m.name, -m.age ] } "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name DESC, users.age DESC" User.select { |m| m.name == 'jon' }.sort_by { |m| -m.age } "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.age DESC" User.select { |m| m.name == 'jon' }.sort_by { |m| -m.profiles.title } "SELECT users.id AS t0_r0, ... FROM users LEFT OUTER JOIN profiles ON profiles.user_id = users.id WHERE (users.name = 'jon') ORDER BY profiles.title DESC" User.select { |m| m.name == 'jon' }.sort_by { rand } "SELECT * FROM users WHERE users.name = 'jon' ORDER BY RAND()" </ruby> h2. COUNT - select { |u| u.name == 'jon' }.size <ruby> User.select { |m| m.name == 'jon' }.size "SELECT count(*) AS count_all FROM users WHERE (users.name = 'jon')" >> User.select { |m| m.name == 'jon' }.size => 21 </ruby> h2. Other Enumerables These methods perform COUNT() operations rather than loading your array into memory. They're all kickers. <ruby> User.any? { |m| m.name == 'jon' } User.all? { |m| m.name == 'jon' } User.select { |m| m.name == 'jon' }.empty? </ruby> h2. More Sugar The @downcase@ and @upcase@ methods will map to LOWER() and UPPER(), respectively. <ruby> >> User.select { |m| m.name.downcase =~ 'jon%' }.to_s => "SELECT * FROM users WHERE LOWER(users.name) LIKE 'jon%'" </ruby> h2. Quoting Columns and values will be quoted using ActiveRecord's quote_column_name and quote methods, if possible. h2. SELECT * FROM bugs Found a bug? Sweet. Add it at "the Lighthouse":https://err.lighthouseapp.com/projects/466-plugins/tickets/new. More information on Ambition: * "https://ambition.rubyforge.org":https://ambition.rubyforge.org * "https://groups.google.com/group/ambition-rb/":https://groups.google.com/group/ambition-rb/ - Chris Wanstrath [ chris@ozmm.org ]
This feature is coming soon. Sit tight!