Merge pull request #3 from ZeusWPI/users-vc
Add index and show action for users
This commit is contained in:
commit
cdce071a91
4 changed files with 57 additions and 0 deletions
|
@ -1,2 +1,9 @@
|
|||
class UsersController < ApplicationController
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def index
|
||||
@users = User.all
|
||||
end
|
||||
end
|
||||
|
|
20
app/views/users/index.html.erb
Normal file
20
app/views/users/index.html.erb
Normal file
|
@ -0,0 +1,20 @@
|
|||
<h2>Users</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Balance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.id %></td>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.balance %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
28
app/views/users/show.html.erb
Normal file
28
app/views/users/show.html.erb
Normal file
|
@ -0,0 +1,28 @@
|
|||
<h2><%= @user.name %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Debtor</th>
|
||||
<th>Creditor</th>
|
||||
<th>Amount</th>
|
||||
<th>Origin</th>
|
||||
<th>Message</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @user.transactions.each do |transaction| %>
|
||||
<tr>
|
||||
<td><%= transaction.id %></td>
|
||||
<td><%= transaction.debtor.name %></td>
|
||||
<td><%= transaction.creditor.name %></td>
|
||||
<td><%= transaction.amount %></td>
|
||||
<td><%= transaction.origin %></td>
|
||||
<td><%= transaction.message %></td>
|
||||
<td><%= transaction.created_at %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -5,6 +5,8 @@ Rails.application.routes.draw do
|
|||
|
||||
root to: 'high_voltage/pages#show', id: "landing"
|
||||
|
||||
resources :users, only: [:show, :index]
|
||||
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
|
|
Loading…
Reference in a new issue