Skip to content

Instantly share code, notes, and snippets.

@patorash
Created December 28, 2015 06:23
Show Gist options
  • Save patorash/90f6d9976461398b3d4b to your computer and use it in GitHub Desktop.
Save patorash/90f6d9976461398b3d4b to your computer and use it in GitHub Desktop.
ransackで検索するときにenum_helpがうまく使えないのでConcernを作った。
module EnumHelpRansack
extend ActiveSupport::Concern
module ClassMethods
def enums_i18n_ransack(enum_name)
enums = eval("self.#{enum_name.to_s.pluralize}")
enums.map { |k, v| [eval("self.#{enum_name.to_s.pluralize}_i18n")[k], v] }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment