Skip to content

Instantly share code, notes, and snippets.

Created September 3, 2010 03:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
$ 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