scaffold accounts

This commit is contained in:
2016-08-27 21:40:21 -05:00
parent 8ff9ca02f8
commit 3d5743b92f
16 changed files with 289 additions and 1 deletions

View File

@ -0,0 +1,2 @@
json.extract! account, :id, :username, :password, :home, :site, :created_at, :updated_at
json.url account_url(account, format: :json)

View File

@ -0,0 +1,37 @@
<%= form_for(account) do |f| %>
<% if account.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(account.errors.count, "error") %> prohibited this account from being saved:</h2>
<ul>
<% account.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :username %>
<%= f.text_field :username %>
</div>
<div class="field">
<%= f.label :password %>
<%= f.text_field :password %>
</div>
<div class="field">
<%= f.label :home %>
<%= f.text_field :home %>
</div>
<div class="field">
<%= f.label :site %>
<%= f.text_field :site %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

@ -0,0 +1,6 @@
<h1>Editing Account</h1>
<%= render 'form', account: @account %>
<%= link_to 'Show', @account %> |
<%= link_to 'Back', accounts_path %>

View File

@ -0,0 +1,33 @@
<p id="notice"><%= notice %></p>
<h1>Accounts</h1>
<table>
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Home</th>
<th>Site</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @accounts.each do |account| %>
<tr>
<td><%= account.username %></td>
<td><%= account.password %></td>
<td><%= account.home %></td>
<td><%= account.site %></td>
<td><%= link_to 'Show', account %></td>
<td><%= link_to 'Edit', edit_account_path(account) %></td>
<td><%= link_to 'Destroy', account, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Account', new_account_path %>

View File

@ -0,0 +1 @@
json.array! @accounts, partial: 'accounts/account', as: :account

View File

@ -0,0 +1,5 @@
<h1>New Account</h1>
<%= render 'form', account: @account %>
<%= link_to 'Back', accounts_path %>

View File

@ -0,0 +1,24 @@
<p id="notice"><%= notice %></p>
<p>
<strong>Username:</strong>
<%= @account.username %>
</p>
<p>
<strong>Password:</strong>
<%= @account.password %>
</p>
<p>
<strong>Home:</strong>
<%= @account.home %>
</p>
<p>
<strong>Site:</strong>
<%= @account.site %>
</p>
<%= link_to 'Edit', edit_account_path(@account) %> |
<%= link_to 'Back', accounts_path %>

View File

@ -0,0 +1 @@
json.partial! "accounts/account", account: @account