我在我的Rails應用程序中有一個自定義的類,它驗證了一堆設置。Rails redirect_to內部自定義類
代碼:
class UserSettingObject < RailsSettings::SettingObject
validate do
if !/^([0-9]|0[0-9]|1[0]):[0-5][0-9]$/.match(self.time)
redirect_to settings_path, notice: 'Invalid time format'
end
end
end
我檢查,以便帖子,發現了類似的問題(here),該建議是include ActionController::Redirecting
但它沒有工作,導致未定義的方法`config_accessor」的錯誤。
如何使用Rails重定向類中的方法?
哈哈,互信:) –
@SergioTulentsev我剛剛意識到,你實際上回答了一個問題,而我提出了一個替代的東西,那是行不通的:) Upvoted –