Ruby on Railsでモデルを介して列の値をnullにする方法は? たとえば、checkbox
呼び出され'include_on_epc'
た とtextbox
呼び出された があり'removal_reason'
ます。
チェックボックスがチェックされている場合、データベースでテキストボックスの値を NULL にする必要があります。
以下を試しましたが、うまくいきません。
class Emm::Rrr::Result < ActiveRecord::Base
before_save :no_removal_reason_when_including_on_epc
private
def no_removal_reason_when_including_on_epc
if include_on_epc == 1
self.removal_reason == nil
end
end
end