Created
December 28, 2015 06:23
-
-
Save patorash/90f6d9976461398b3d4b to your computer and use it in GitHub Desktop.
ransackで検索するときにenum_helpがうまく使えないのでConcernを作った。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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