From 0eb05d8b72cecd6de295de635709744da3224b40 Mon Sep 17 00:00:00 2001 From: victorloo Date: Wed, 31 Jan 2018 15:55:44 +0800 Subject: [PATCH] add show page --- app/controllers/users_controller.rb | 4 ++++ app/views/users/show.html.erb | 16 ++++++++++++++++ config/routes.rb | 1 + 3 files changed, 21 insertions(+) create mode 100644 app/views/users/show.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a614607..8f537ef 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,4 +4,8 @@ def index @users = User.all end + def show + @user = User.find(params[:id]) + end + end \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 0000000..d30a19c --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,16 @@ +

User Profile

+ + + + + + + + + + +
Name: + <%= @user.name %> +
Role: + <%= @user.role %> +
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 149da05..16b9876 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,4 +2,5 @@ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root "users#index" + resources :users end