Skip to content

Instantly share code, notes, and snippets.

@jimsynz
Created September 3, 2010 03:58
Show Gist options
  • Save jimsynz/563393 to your computer and use it in GitHub Desktop.
Save jimsynz/563393 to your computer and use it in GitHub Desktop.
$ gem install rails --version=3.0.0
$ rails new ArelBug
$ cd ArelBug
$ rails generate model post text:string type:string
$ rails generate model mention post_id:integer user_id:integer
$ rake db:create db:migrate
$ rails console
> pt = Post.arel_table
> mt = Mention.arel_table
# SELECT "posts"."id" FROM "mentions" INNER JOIN "posts" ON "posts"."id" = "mentions"."post_id" WHERE "mentions"."user_id" = 14 AND "posts"."type" != 'ReTweet'
> Benchmark.measure { mt.join(pt).on(pt[:id].eq(mt[:post_id])).where(mt[:user_id].eq(14)).where(pt[:type].eq('ReTweet').not).project(pt[:id]) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment