Skip to content

Instantly share code, notes, and snippets.

@axtutuu
Last active October 5, 2016 06:42
Show Gist options
  • Save axtutuu/73b5d56fb66b8bc17eae748d523c9fa1 to your computer and use it in GitHub Desktop.
Save axtutuu/73b5d56fb66b8bc17eae748d523c9fa1 to your computer and use it in GitHub Desktop.
マッチした attributes を配列で取り出す
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