Skip to content

Instantly share code, notes, and snippets.

@wtnabe
Created January 25, 2011 01:08
Show Gist options
  • Save wtnabe/794333 to your computer and use it in GitHub Desktop.
Save wtnabe/794333 to your computer and use it in GitHub Desktop.
validates with class methods ( validates_* なヘルパーはクラスメソッドです!)
# -*- mode: ruby -*-
class Klass < ActiveRecord::Base
# "undefined ..."
validates_inclusion_of :in => values
# success !
validates_inclusion_of :in => self.values
# cannot be called
def values; end
# can be called
def self.values; end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment