Merge pull request #3 from ZeusWPI/users-vc

Add index and show action for users
This commit is contained in:
benji 2015-09-08 17:29:10 +02:00
commit cdce071a91
4 changed files with 57 additions and 0 deletions

View file

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

View 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>

View 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>

View file

@ -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".