2
我正在使用chargify_api_ares
gem來搜索Chargify訂閱。重定向如果沒有找到對象
@current_subscription = Chargify::Subscription.find_by_customer_reference(@dealer.id)
redirect_to(dealers_path) unless @current_subscription
然而,如果沒有訂閱發現它永遠不會使它對地方重定向因爲find_by_customer_reference
吐出404,如果未發現任何下一行,但我想一些方法它返回nil
取而代之的是,我可以將它轉到下一行,我將用戶從那裏重定向。
有誰知道我可以如何輕鬆地失敗或更好的方式我可以重定向用戶,如果沒有對象被發現?謝謝。
謝謝!這個伎倆。實際上我不得不「拯救ActiveResource :: ResourceNotFound」,但是。謝謝。 –