3
모델 클래스 메서드에서 실행하고 메서드를 찾을 수없는 오류가 발생하도록 도우미 메서드를 만들었습니다.모델 클래스 메서드에서 도우미 메서드 실행
lib 디렉토리/model_helper
module ModelHelper
def method_i_want_to_use
puts "I want to use this method"
end
end
모델/foo는
class Foo < ActiveRecord::Base
include ModelHelper
def self.bar
method_i_want_to_use
end
end
이 설정은 나에게 어떤 방법 오류를 제공합니다.
모델에서 헬퍼를 사용하지 마십시오.이 모델은 헬퍼를 사용하지 않습니다. 우려를 대신 사용하십시오. – BroiSatse
@BroiSatse True .. 그리고 맞습니다. –