:before_create
메서드를 사용하여 확인을 수행하고 false
또는 true
을 반환하는 메서드가 있습니다. 이 방법은 false
또는 nil
을 반환하는 경우false 또는 nil 일 때 before_create 메서드가 저장되지 않도록합니다.
def create_subscription_on_gateway
gateway = self.keyword.shortcode.provider
create_subscription = gateway.classify.constantize.new.create_subscription(self.phone,self.keyword_keyword,self.shortcode_shortcode,self.country)
errors[:base] << "An error has occurred when finding gateway." if gateway.nil?
errors[:base] << "No gateway found for this shortcode." if create_subscription.nil?
errors[:base] << "Subscription could not be made." if create_subscription == false
end
지금, 나는 괜찮 양식 페이지에 오류를 볼 수 있습니다. 문제는 개체가 데이터베이스에 저장되었다는 것입니다.
오류가 여전히 관련되어있을 때 개체를 저장하지 못하게하려면 어떻게해야합니까?