我正在嘗試使用Rail的distance_of_time_in_words
幫助程序,但由於某種原因我收到了未定義的方法錯誤。這裏是我的代碼:Rails 3中使用distance_of_time_in_words 3
def confirm_has_quota
last_upload = current_user.photos.last.created_at
remaining_time = distance_of_time_in_words(1.day.ago, last_upload)
if last_upload < 1.day.ago
return true
else
flash[:error] = "You are allowed 1 upload per day. Please try again in" + remaining_time + "."
redirect_to(:back)
end
end
這給了我 「未定義的方法`distance_of_time_in_words'」。有人看到我在這裏做錯了嗎?謝謝。