File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 33class MainController < ApplicationController
44 layout 'landing' , only : [ :index , :about_notebook ]
55
6+ class RetryMe < StandardError ; end
7+
68 def index
79 redirect_to :dashboard if user_signed_in?
810 end
@@ -16,7 +18,16 @@ def comingsoon
1618 def dashboard
1719 return redirect_to new_user_session_path unless user_signed_in?
1820
19- @content = current_user . content . values . flatten . sample
20- @question = @content . question unless @content . nil?
21+ # Try up to 5 times to actually fetch a question
22+ attempts = 0
23+
24+ begin
25+ @content = current_user . content . values . flatten . sample
26+ @question = @content . question unless @content . nil?
27+
28+ raise RetryMe if @question . nil? || @question [ :question ] . nil? # :(
29+ rescue RetryMe
30+ retry if attempts < 5
31+ end
2132 end
2233end
You can’t perform that action at this time.
0 commit comments