Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Rails3.xbefore_validation(:on => :create) doは機能しません。他のアイデアはありがたい
before_validation(:on => :create) do
これは私が素晴らしい作品をしたことです。
before_validation do if self.new_record? # do something here end end
次の方法でコールバックに条件を追加できます。
before_validation :do_something, :unless => Proc.new { |model| model.persisted? }