Skip to content

Instantly share code, notes, and snippets.

ruby-1.8.7-p249 > posts = Post.all
Post Load (0.4ms) SELECT * FROM "posts"
Post::Translation Load (0.4ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 2)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 2)
+----+--------
Output root of a given branch (second commit from the top of the output)
git for-each-ref refs/heads | while read sha rest; do git merge-base $sha <branchname>; done | git log --date-order --no-walk --stdin
#!/bin/sh
#
# PROVIDE: cccms
# REQUIRE: nginx cleanvar
. /etc/rc.subr
name=cccms
rcvar=`set_rcvar`
# put this in RAILS_ROOT/lib
module AccessToken
class << self
def current=(token)
Thread.current[:token] = token
end
def current
From c10e9ebe037cd6671cfe250dff9c8289d524bc3a Mon Sep 17 00:00:00 2001
From: hukl <[email protected]>
Date: Mon, 3 Aug 2009 16:54:06 +0200
Subject: [PATCH] helper method to create translation table no considers table_prefixes
---
lib/globalize/model/active_record/translated.rb | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/globalize/model/active_record/translated.rb b/lib/globalize/model/active_record/translated.rb
klass.send :define_method, "translated_#{attr_name}", lambda {|*loc|
loc = loc.first || I18n.locale
globalize.fetch loc, attr_name
}
klass.send :define_method, "set_translated_#{attr_name}", lambda {|loc, val|
globalize.stash loc, attr_name, val
self[attr_name] = val
}
class Object
# The hidden singleton lurks behind everyone
def metaclass
class << self
self
end
end
def meta_eval &blk
metaclass.instance_eval &blk
class Object
def metaclass
class << self; self; end
end
end
class Foo
def self.hello
puts "hello"
end