File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class PlansController < BaseApiController # rubocop:todo Style/Documentation
1010 def show
1111 raise Pundit ::NotAuthorizedError unless @scopes . include? ( 'read' )
1212
13- @plan = Plan . find_by ( id : params [ :id ] )
13+ @plan = Plan . includes ( roles : :user ) . find ( params [ :id ] )
1414
1515 raise Pundit ::NotAuthorizedError unless @plan . present?
1616
Original file line number Diff line number Diff line change @@ -60,16 +60,17 @@ def plan_costs(plan:)
6060
6161 # Fetch all questions and answers from a plan, regardless of theme
6262 def fetch_all_q_and_a
63- return [ ] unless @plan . questions . present?
63+ answers = @plan . answers . includes ( :question )
64+ return [ ] unless answers . present?
6465
65- @plan . questions . filter_map do |q |
66- a = @plan . answers . find { | ans | ans . question_id == q . id }
67- next unless a . present?
66+ answers . filter_map do |answer |
67+ q = answer . question
68+ next unless q . present?
6869
6970 {
7071 title : "Question #{ q . number || q . id } " ,
7172 question : q . text . to_s ,
72- answer : a . text . to_s
73+ answer : answer . text . to_s
7374 }
7475 end
7576 end
You can’t perform that action at this time.
0 commit comments