瀏覽代碼

Add User profile page

Frans Bergman 7 年之前
父節點
當前提交
5d196f0da7
共有 4 個文件被更改,包括 23 次插入0 次删除
  1. 6 0
      app/assets/stylesheets/users.scss
  2. 5 0
      app/controllers/users_controller.rb
  3. 10 0
      app/views/users/show.html.erb
  4. 2 0
      config/routes.rb

+ 6 - 0
app/assets/stylesheets/users.scss

@@ -1,3 +1,9 @@
 // Place all the styles related to the Users controller here.
 // They will automatically be included in application.css.
 // You can use Sass (SCSS) here: http://sass-lang.com/
+
+.user-info {
+  h1 {
+    font-size: 2em;
+  }
+}

+ 5 - 0
app/controllers/users_controller.rb

@@ -1,4 +1,9 @@
 class UsersController < ApplicationController
+
+  def show
+    @user = User.find(params[:id])
+  end
+
   def new
   end
 end

+ 10 - 0
app/views/users/show.html.erb

@@ -0,0 +1,10 @@
+<% provide(:title, @user.name) %>
+<div class="row">
+  <aside class="col-md-4">
+    <section class="user-info">
+      <h1>
+        <%= @user.name %>
+      </h1>
+    </section>
+  </aside>
+</div>

+ 2 - 0
config/routes.rb

@@ -5,4 +5,6 @@ Rails.application.routes.draw do
 
   get '/home', to: 'static_pages#home'
   get '/about', to: 'static_pages#about'
+
+  resources :users
 end