diff --git a/rails_root/app/controllers/home_controller.rb b/rails_root/app/controllers/home_controller.rb index 2c39734..997387c 100644 --- a/rails_root/app/controllers/home_controller.rb +++ b/rails_root/app/controllers/home_controller.rb @@ -3,8 +3,11 @@ # Controller for the home page class HomeController < ApplicationController def index - @survey_responses = SurveyResponse.where(profile_id: 2) # FIXME: use code below when other part works - # @survey_profile = SurveyProfile.find_by(user_id: session[:userinfo]["sub"]) - # @survey_responses = SurveyResponse.where(profile_id: session[:userinfo]["sub"]) + return if session[:userinfo].nil? + + @survey_profile = SurveyProfile.find_by(user_id: session[:userinfo]['sub']) + return if @survey_profile.nil? + + @survey_responses = SurveyResponse.where(profile_id: @survey_profile.id) end end diff --git a/rails_root/app/views/home/index.html.erb b/rails_root/app/views/home/index.html.erb index 4e8f468..0244e7d 100644 --- a/rails_root/app/views/home/index.html.erb +++ b/rails_root/app/views/home/index.html.erb @@ -4,6 +4,11 @@ <% if session[:userinfo].present? %>