Last active
October 5, 2016 06:42
-
-
Save axtutuu/73b5d56fb66b8bc17eae748d523c9fa1 to your computer and use it in GitHub Desktop.
マッチした attributes を配列で取り出す
This file contains 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
class HogeModel | |
# fugaにマッチしたカラムの返却 | |
def fuga_columns | |
self.attributes.keys.select { |a| a.match(/fuga/) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment