diff --git a/app/controllers/students_controller.rb b/app/controllers/students_controller.rb new file mode 100644 index 0000000..bab058a --- /dev/null +++ b/app/controllers/students_controller.rb @@ -0,0 +1,11 @@ +class StudentsController < ApplicationController + before_action :set_student, only: %i[show] + + def show; end + + private + + def set_student + @student = Student.find(params[:id]) + end +end diff --git a/app/views/students/show.html.erb b/app/views/students/show.html.erb new file mode 100644 index 0000000..3c21280 --- /dev/null +++ b/app/views/students/show.html.erb @@ -0,0 +1,7 @@ +
+

Email: <%= @student.email %>

+
+ +
+

Cash Balance: <%= number_to_currency(@student&.portfolio&.cash_balance) %>

+
diff --git a/config/routes.rb b/config/routes.rb index a836d68..76ad555 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,7 @@ devise_for :users resources :classrooms resources :schools + resources :students, only: [:show] # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. diff --git a/test/controllers/students_controller_test.rb b/test/controllers/students_controller_test.rb new file mode 100644 index 0000000..f3ff2eb --- /dev/null +++ b/test/controllers/students_controller_test.rb @@ -0,0 +1,12 @@ +require 'test_helper' + +class StudentsControllerTest < ActionDispatch::IntegrationTest + setup do + @student = users(:one) + end + + test 'should show student' do + get student_url(@student) + assert_response :success + end +end