scaffold accounts
This commit is contained in:
2
app/views/accounts/_account.json.jbuilder
Normal file
2
app/views/accounts/_account.json.jbuilder
Normal file
@ -0,0 +1,2 @@
|
||||
json.extract! account, :id, :username, :password, :home, :site, :created_at, :updated_at
|
||||
json.url account_url(account, format: :json)
|
37
app/views/accounts/_form.html.erb
Normal file
37
app/views/accounts/_form.html.erb
Normal 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 %>
|
6
app/views/accounts/edit.html.erb
Normal file
6
app/views/accounts/edit.html.erb
Normal file
@ -0,0 +1,6 @@
|
||||
<h1>Editing Account</h1>
|
||||
|
||||
<%= render 'form', account: @account %>
|
||||
|
||||
<%= link_to 'Show', @account %> |
|
||||
<%= link_to 'Back', accounts_path %>
|
33
app/views/accounts/index.html.erb
Normal file
33
app/views/accounts/index.html.erb
Normal 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 %>
|
1
app/views/accounts/index.json.jbuilder
Normal file
1
app/views/accounts/index.json.jbuilder
Normal file
@ -0,0 +1 @@
|
||||
json.array! @accounts, partial: 'accounts/account', as: :account
|
5
app/views/accounts/new.html.erb
Normal file
5
app/views/accounts/new.html.erb
Normal file
@ -0,0 +1,5 @@
|
||||
<h1>New Account</h1>
|
||||
|
||||
<%= render 'form', account: @account %>
|
||||
|
||||
<%= link_to 'Back', accounts_path %>
|
24
app/views/accounts/show.html.erb
Normal file
24
app/views/accounts/show.html.erb
Normal 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 %>
|
1
app/views/accounts/show.json.jbuilder
Normal file
1
app/views/accounts/show.json.jbuilder
Normal file
@ -0,0 +1 @@
|
||||
json.partial! "accounts/account", account: @account
|
Reference in New Issue
Block a user