Skip to content

Instantly share code, notes, and snippets.

@rainchen
Created September 25, 2012 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rainchen/3779939 to your computer and use it in GitHub Desktop.
Save rainchen/3779939 to your computer and use it in GitHub Desktop.
this patch allowed to use a proc to :label option, then we can pass a proc to ActiveAdmin `filter` method
# ActiveAdmin use Formtastic as the "filter" field builder
# this patch allowed to use a proc to :label option, then we can pass a proc to `filter` method
# e.g.: filter :foo, :label => proc { I18n.tr('activerecord.attributes.foo.bar') }
module Formtastic
class Localizer
def localize_with_proc_value(key, value, type, options = {})
if value.is_a?(::Proc)
value.call(key)
else
localize_without_proc_value(key, value, type, options = {})
end
end
alias_method_chain :localize, :proc_value
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment